Coder Social home page Coder Social logo

inproc's People

Contributors

owaiskazi19 avatar

Watchers

 avatar

inproc's Issues

[PROPOSAL - IN PROC Support] Run a process within the same JVM

With the current extension framework, extensions are running out of process or remote node from OpenSearch cluster. This proposal talks about the multiple approaches a process can be run within the same JVM.

  1. ProcessBuilder method create a native process and return an instance of a subclass of Process that can be used to control the process and obtain information about it.
ProcessBuilder pb = new ProcessBuilder(<Process>);
Process process = pb.start();
  1. Runtime.getRuntime().exec method returns a new Process object for managing the subprocess
Process process = Runtime.getRuntime().exec("ls");
  1. Multithreading
new Thread() {
  public void run() {
   <Process>
  }
}.start();

Results:
Using the command Java Virtual Process Status(jps) the results were found that only a single JVM is spun up for the Main method of the Java File and all the 3 approaches mentioned above doesn't create a new JVM to run rather runs in the same process as the JVM of Main

When a simple java file is running which prints Hello World!:

77587 jdk.jcmd/sun.tools.jps.Jps -mlv -Dapplication.home=/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home -Xms8m -Djdk.module.main=jdk.jcmd
77541 jdk.compiler/com.sun.tools.javac.launcher.Main ProcessBuilderExtensions.java --add-modules=ALL-DEFAULT
31564  -Xms128m -Xmx750m -XX:ReservedCodeCacheSize=512m -XX:+IgnoreUnrecognizedVMOptions -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -ea -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off -XX:ErrorFile=/Users/kazabdu/java_error_in_idea_%p.log -XX:HeapDumpPath=/Users/kazabdu/java_error_in_idea.hprof -Xmx2500m -Djb.vmOptionsFile=/Users/kazabdu/Library/Application Support/JetBrains/IntelliJIdea2021.3/idea.vmoptions -Dsplash=true -Didea.home.path=/Applications/IntelliJ IDEA.app/Contents -Didea.jre.check=true -Didea.executable=idea -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.paths.selector=IntelliJIdea2021.3 -Didea.vendor.name=JetBrains

When the any of the above 3 approach is running a new process within the same JVM:

77861 jdk.compiler/com.sun.tools.javac.launcher.Main ProcessBuilderExtensions.java --add-modules=ALL-DEFAULT
31564  -Xms128m -Xmx750m -XX:ReservedCodeCacheSize=512m -XX:+IgnoreUnrecognizedVMOptions -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -ea -Dsun.io.useCanonCaches=false -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.attach.allowAttachSelf=true -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off -XX:ErrorFile=/Users/kazabdu/java_error_in_idea_%p.log -XX:HeapDumpPath=/Users/kazabdu/java_error_in_idea.hprof -Xmx2500m -Djb.vmOptionsFile=/Users/kazabdu/Library/Application Support/JetBrains/IntelliJIdea2021.3/idea.vmoptions -Dsplash=true -Didea.home.path=/Applications/IntelliJ IDEA.app/Contents -Didea.jre.check=true -Didea.executable=idea -Djava.system.class.loader=com.intellij.util.lang.PathClassLoader -Didea.paths.selector=IntelliJIdea2021.3 -Didea.vendor.name=JetBrains
78044 jdk.jcmd/sun.tools.jps.Jps -mlv -Dapplication.home=/Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home -Xms8m -Djdk.module.main=jdk.jcmd

The above result clearly shows that only a single JVM process is running with the above 3 approaches mentioned.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.