igniterealtime / openfire-pade-plugin

A plugin for Openfire that offers web-based unified communications - chat, groupchat, telephone, audio and video conferencing.
Apache License 2.0
57 stars 30 forks source link

OpenJDK 15 and UseConcMarkSweepGC #114

Closed iamnacho closed 3 years ago

iamnacho commented 4 years ago

I'm using 1.1.2 and am seeing JvbPluginWarpper not start correctly due to option "UseConcMarkSweepGC":

[Thread-16] INFO org.jivesoftware.openfire.plugin.ofmeet.JvbPluginWrapper - Unrecognized VM option 'UseConcMarkSweepGC' java[2544]: 11:18:56.192 [pool-7-thread-3] INFO org.jivesoftware.openfire.plugin.ofmeet.JvbPluginWrapper - Successfully initialized Jitsi Videobridge. java[2544]: /usr/lib64/jvm/java-15-openjdk-15/bin/java -Xmx3072m -XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -Dconfig.file=/opt/openfire/plugins/ofmeet/classes/jvb/application.conf -Dnet.java.sip.communicator.SC_HOME_DIR_LOCATION=/opt/openfire/plugins/ofmeet/classes/jvb -Dnet.java.sip.communicator.SC_HOME_DIR_NAME=config -Djava.util.logging.config.file=./logging.properties -Djdk.tls.ephemeralDHKeySize=2048 -cp /opt/openfire/plugins/ofmeet/classes/jvb/jitsi-videobridge.jar:/opt/openfire/plugins/ofmeet/classes/jvb/jitsi-videobridge-2.1-SNAPSHOT-jar-with-dependencies.jar org.jitsi.videobridge.MainKt --apis=rest java[2544]: 11:18:56.192 [Thread-17] INFO org.jivesoftware.openfire.plugin.ofmeet.JvbPluginWrapper - onProcessQuit 1 java[2544]: 11:18:56.193 [Thread-16] INFO org.jivesoftware.openfire.plugin.ofmeet.JvbPluginWrapper - Error: Could not create the Java Virtual Machine. java[2544]: 11:18:56.193 [Thread-16] INFO org.jivesoftware.openfire.plugin.ofmeet.JvbPluginWrapper - Error: A fatal exception has occurred. Program will exit.

If I manually start the java process without the "-XX+UseConcMarkSweepGC" it appears to start correctly (and my JVB user logs in.)

Is it possible that this option has been removed from JDK 15 ? (Internet searching for this value shows that some other open-source projects have user request for similar problems of process not starting when this option is used and Java has been upgraded to v 15) Is there a way for me to remove this value by default when starting this part of the plugin ? (so that I do not need to manually start it?)

Thank you!

deleolajide commented 4 years ago

Is there a way for me to remove this value by default when starting this part of the plugin

Create a system property called org.jitsi.videobridge.ofmeet.jvb.jvm.customOptions and set your own startup options. The default value is

"-Xmx3072m -XX:+UseConcMarkSweepGC -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp"

See https://github.com/igniterealtime/openfire-pade-plugin/blob/e9523c0f299617ddfdd5ab3216358ecea8c17339/ofmeet/src/java/org/jivesoftware/openfire/plugin/ofmeet/JvbPluginWrapper.java#L164

gjaekel commented 4 years ago

The ConcurrentMarkSweep GC has been removed in Java15.

@deleolajide: Blame on me, I forgot to discuss the options default you choose. Fortunately, we have build in this custom options with #92.

@iamnacho Note: There's a similar org.jitsi.videobridge.ofmeet.focus.jvm.customOptions property.

The Jitsi project seems to choose ConcurrentMarkSweep GC in former to a short stop time. In this days, I recommend to use G1GC (-XX:+UseG1GC) in conjunction with a stop-world target time (-XX:MaxGCPauseMillis=50).

As a reference, here my current option set used for a Java8-JVM: -XX:+UseG1GC -Xms64m -Xmx256m -XX:MaxMetaspaceSize=128M -XX:MaxDirectMemorySize=64M -XX:MaxGCPauseMillis=50 -XX:ConcGCThreads=5 -XX:+ParallelRefProcEnabled -XX:ParallelGCThreads=5 -XX:ActiveProcessorCount=20 -XX:+UseStringDeduplication -Djava.io.tmpdir=/var/tmp -Djava.net.preferIPv4Stack=true -Dsun.net.inetaddr.ttl=60

iamnacho commented 4 years ago

Thank you deleolajide and gjaekel . I set a value of -Xmx3072m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -XX:+UseG1GC -XX:MaxGCPauseMillis=50 for org.jitsi.videobridge.ofmeet.jvb.jvm.customOptions & restarted my openfire service and it looks like the process started. :-)

gjaekel commented 3 years ago

@deleolajide

Theoretically there's exist a JVM option -XX:+IgnoreUnrecognizedVMOptions, but it seems that this available since Java9 - so it's a chicken-egg-situation.

We may determine the version of the Jetty JVM to choose an appropriate default option set for the JVB and JiCoFo ones.

Something like the following may help to struggle with the old (1.x.y.z) and new (x.y.z) version format used since Java9

private static int getJvmMajorVersion() {
    String version = System.getProperty("java.version");
    if(version.startsWith("1.")) {
        version = version.substring(2, 3);
    } else {
        int dot = version.indexOf(".");
        if(dot != -1) { version = version.substring(0, dot); }
    } return Integer.parseInt(version);
}