Java Flight Recorder and JDK Mission Control : Method sampling not including methods of java.nio package?

173 Views Asked by At

I suspected a method in my code to be very slow when listing files in a directory containing thousands of files (more than 60s). So I put some logs in my code and it confirmed me that this part was slow. It then used JFR to see if it was correctly reporting this hugely slow method.

The associated thread dump is :

"EJB default - 5 : Task-XML_MON" #522 prio=5 os_prio=0 cpu=8362437.50ms elapsed=86380.31s tid=0x000001c5d122c000 nid=0x594c runnable  [0x0000001cb04fd000]
   java.lang.Thread.State: RUNNABLE
    at sun.nio.fs.WindowsNativeDispatcher.CreateFile0([email protected]/Native Method)
    at sun.nio.fs.WindowsNativeDispatcher.CreateFile([email protected]/WindowsNativeDispatcher.java:71)
    at sun.nio.fs.WindowsChannelFactory.open([email protected]/WindowsChannelFactory.java:308)
    at sun.nio.fs.WindowsChannelFactory.newFileChannel([email protected]/WindowsChannelFactory.java:168)
    at sun.nio.fs.WindowsFileSystemProvider.checkReadAccess([email protected]/WindowsFileSystemProvider.java:326)
    at sun.nio.fs.WindowsFileSystemProvider.checkAccess([email protected]/WindowsFileSystemProvider.java:363)
    at sun.nio.fs.AbstractFileSystemProvider.exists([email protected]/AbstractFileSystemProvider.java:151)
    at java.nio.file.Files.exists([email protected]/Files.java:2434)
    at org.apache.commons.io.file.CountingPathVisitor.visitFile(CountingPathVisitor.java:151)
    at org.apache.commons.io.file.CountingPathVisitor.visitFile(CountingPathVisitor.java:35)
    at java.nio.file.Files.walkFileTree([email protected]/Files.java:2724)
    at org.apache.commons.io.FileUtils.listAccumulate(FileUtils.java:2076)
    at org.apache.commons.io.FileUtils.listFiles(FileUtils.java:2132)

This thread dump comes from a JFR recording (in 'profile' mode) that I started when I knew for sure that my application was running my slow method (listing the files of a directory through the call of FileUtils.listFiles() which calls java.nio.file.Files.walkFileTree()).

I stopped the recording after about 60s and opened it in JMC.

I was then very surprised to see absolutely no warning from the automatic analysis and futhermore surprised to not see my method listed in the "Method profiling" section. All I saw was this :

enter image description here

Why is FileUtils.listFiles not present in the "Method profiling" knowing it was running for the whole time of the recording ?

Does it mean that the java.nio methods (here java.nio.file.Files.walkFileTree in particular) are not sampled by JFR ?

It is really hard to detect this type of bottleneck if JFR or JMC cannot provide this kind of information.

0

There are 0 best solutions below