简体   繁体   中英

System.exit appears to take a long time on OpenJDK 7 / FreeBSD

I'm having a problem with the performance of a Java subprocess running under Java, running on FreeBSD 9.0-RELEASE i386.

System.exit(), for this program, takes about 2.6 seconds to run. And I can't figure out why. It takes 0.025 seconds on Windows. Update: It also runs much faster on OpenJDK 6.

Running OpenJDK7 under ktrace reveals, during shutdown, a huge sequence of the following:

26795 java 1.808597 CALL _umtx_op(0x2831e068,0xf,0,0,0xbf7a9870)
26795 java 1.838640 RET _umtx_op -1 errno 60 Operation timed out

How can I figure out what the program is trying to do here? Or, is there an easy workaround or way to fix this? It looks like this problem comes up at the OS level on FreeBSD pretty frequently, judging by web searching, but I'm still analyzing what I'm finding (and trying to learn libthr and so forth).

There are no shutdown hooks added by me other than one to print a timestamp, no shutdown hooks added by the system, no files to delete, and no runFinalizersOnExit. The system seems to be spending the time in the native method java.lang.Shutdown.halt0, which I am still trying to analyze.

The operand 0xf is UMTX_OP_WAKE_PRIVATE (see /usr/src/sys/sys/umtx.h ). This tries to wake up a kernel thread, and fails.

Now as to why it fails is impossible to say. It could be a deadlock in java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM