You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's the current summary of unit test times on my Windows desktop:
The fact that the whole reactor takes 6 minutes is prohibitive for development.
I am in favor of having a single Ops environment that gets reused across tests, at least for default builds. For CI we could have full encapsulation and rebuild the environment each time.
I agree and have been meaning to file an issue about this, thanks. We should reuse the same environment, yeah. Also on CI, because I think slow CI is also a hindrance.
@hinerm's PR scijava/incubator#65 improves matters. Still room for further optimization, but imagej-ops2 has a lot of tests, some of which are computationally intensive, so there will be limits to how lightning-quick we can make it. @hinerm Are you OK closing this issue now, or do you want to leave it open till we have time to do another optimization pass?
I did some profiling with the JDK Flight Recorder + VisualVM. Nothing definitive to report so far, but here is an explanation of what I did, and things I saw that probably merit further investigation:
I wanted to profile the scijava incubator code using IntelliJ. Unfortunately, the Community edition of IDEA does not have profiling tools integrated into the IDE. So I turned to the JDK Flight Recorder (JFR), which is open source as of OpenJDK 11. You can enable it by creating a run configuration with an additional flag: -XX:StartFlightRecording:filename="/home/curtis/Desktop/imagej-ops2.jfr" which points to where you want your JFR capture to be saved. Then launch that run configuration to generate it.
The next part, which I found a little tricky, is getting a VisualVM installed that supports JFR files. The VisualVM I installed on Ubuntu via apt install visualvm, v2.0.6, does not support JFR files out of the box; when you try to load one, it tells you to install a plugin called VisualVM-JFR-Generic, but it's not actually available on the list when you try. So an easier path forward for me was to download GraalVM 22.3.0, and then install its VisualVM support, which is done simply via bin/gu install visualvm, at which point it appears as jvisualvm in the GraalVM installation's bin folder.
Then you can launch VisualVM and open up the JFR file using File → Load... A tab will open with an overview.
There is another set of tabs on the bottom of the GUI with other views; the Sampler tab here is interesting. Click it.
Then click the CPU button.
Then click the "Hot spots" view (tiny table-icon button next to arrow button in the View toolbar).
The computeBin methods of the various thresholding methods appear a lot; maybe we can improve how those get used, and/or optimize any of those implementations.
In the "Forward calls" view (the arrow button, enabled initially after clicking CPU), filtering by scijava (by right-clicking any thread and choosing "Filter" from the popup menu), we can also see that therapi methods are in the news a lot. So our plan to discover as efficiently as possible by loading op specifications from YAML files instead is likely going to improve runtime performance here as well.
This Medium article is also potentially interesting, but I haven't gone through it in depth yet.
So I'm still getting familiar with analyzing JFR output but have been looking at a capture of the LilCQTest
I looked at the Hot Spots in the Sampler tab > CPU and it says 1.2s were spent creating java.lang.Error. If you right-click on an entry in Hot Spots and go to "Find in Forward Calls" it will highlight one execution path to that item. You can continue to click and "Find in Forward Calls" to cycle through use-cases. (You can also do this with Reverse Calls but I find Forward a little easier to mentally parse).
Some items I've found:
338ms in net.imagej.ops.ops2.Creators.<init>
468ms creating synthesized parameters
240ms getting therapi javadoc
A total of ~1.5s checking File.exists() in SCIFIO when opening the different images for this test
A significant amount of time doing disk IO with therapi:
SJC2, but yeah. SCIFIO is built on SciJava Common, so we're not getting away from this at test time unless: A) we stop using SCIFIO; or B) we port SCIFIO to the incubator and change its plugin model to use JPMS instead.
@hinerm@ctrueden this issue provides no concrete milestones (i.e. how fast is fast enough to consider this issue closed), I'm going to close this issue and make smaller issues for the particular issues @hinerm (and now I) am finding:
Activity
ctrueden commentedon Oct 31, 2022
I agree and have been meaning to file an issue about this, thanks. We should reuse the same environment, yeah. Also on CI, because I think slow CI is also a hindrance.
ctrueden commentedon Nov 8, 2022
@hinerm's PR scijava/incubator#65 improves matters. Still room for further optimization, but imagej-ops2 has a lot of tests, some of which are computationally intensive, so there will be limits to how lightning-quick we can make it. @hinerm Are you OK closing this issue now, or do you want to leave it open till we have time to do another optimization pass?
hinerm commentedon Nov 8, 2022
@ctrueden let's do a run of profiling the tests and then if that doesn't turn up anything obvious we can close this issue!
ctrueden commentedon Nov 8, 2022
I did some profiling with the JDK Flight Recorder + VisualVM. Nothing definitive to report so far, but here is an explanation of what I did, and things I saw that probably merit further investigation:
I wanted to profile the scijava incubator code using IntelliJ. Unfortunately, the Community edition of IDEA does not have profiling tools integrated into the IDE. So I turned to the JDK Flight Recorder (JFR), which is open source as of OpenJDK 11. You can enable it by creating a run configuration with an additional flag:
-XX:StartFlightRecording:filename="/home/curtis/Desktop/imagej-ops2.jfr"which points to where you want your JFR capture to be saved. Then launch that run configuration to generate it.The next part, which I found a little tricky, is getting a VisualVM installed that supports JFR files. The VisualVM I installed on Ubuntu via
apt install visualvm, v2.0.6, does not support JFR files out of the box; when you try to load one, it tells you to install a plugin calledVisualVM-JFR-Generic, but it's not actually available on the list when you try. So an easier path forward for me was to download GraalVM 22.3.0, and then install its VisualVM support, which is done simply viabin/gu install visualvm, at which point it appears asjvisualvmin the GraalVM installation'sbinfolder.Then you can launch VisualVM and open up the JFR file using File → Load... A tab will open with an overview.
computeBinmethods of the various thresholding methods appear a lot; maybe we can improve how those get used, and/or optimize any of those implementations.scijava(by right-clicking any thread and choosing "Filter" from the popup menu), we can also see that therapi methods are in the news a lot. So our plan to discover as efficiently as possible by loading op specifications from YAML files instead is likely going to improve runtime performance here as well.This Medium article is also potentially interesting, but I haven't gone through it in depth yet.
hinerm commentedon Nov 9, 2022
So I'm still getting familiar with analyzing JFR output but have been looking at a capture of the
LilCQTestI looked at the Hot Spots in the Sampler tab > CPU and it says 1.2s were spent creating
java.lang.Error. If you right-click on an entry in Hot Spots and go to "Find in Forward Calls" it will highlight one execution path to that item. You can continue to click and "Find in Forward Calls" to cycle through use-cases. (You can also do this with Reverse Calls but I find Forward a little easier to mentally parse).Some items I've found:
338ms in

net.imagej.ops.ops2.Creators.<init>468ms creating synthesized parameters

240ms getting therapi javadoc

A total of ~1.5s checking

File.exists()in SCIFIO when opening the different images for this testA significant amount of time doing disk IO with therapi:

I also noticed we are creating a SJ1 context?

ctrueden commentedon Nov 10, 2022
Thanks @hinerm for digging!
SJC2, but yeah. SCIFIO is built on SciJava Common, so we're not getting away from this at test time unless: A) we stop using SCIFIO; or B) we port SCIFIO to the incubator and change its plugin model to use JPMS instead.
gselzer commentedon Sep 7, 2023
@hinerm @ctrueden this issue provides no concrete milestones (i.e. how fast is fast enough to consider this issue closed), I'm going to close this issue and make smaller issues for the particular issues @hinerm (and now I) am finding:
I could not replicate this so I'm ignoring it.
I could replicate this - see #131
I could replicate this, but I'm going to ignore it for now because scijava/incubator#79 will remove the therapi javadoc parsing.
I could not replicate this so I'm ignoring it.
See above with the therapi stuff.
It's probably worth running the profiler again once we get the YAML work merged, to see if that pathway exhibits the same performance issues...
Merge pull request #102 from scijava/scijava/scijava-ops-engine/parse…