-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
- Loading branch information
There are no files selected for viewing
4 comments
on commit dd5a3e3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addresses issue #600
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VisualVM CPU profiling suggests the problem is in:
fillNeighborhood()
(but not really getAtLocation()
, surprisingly; maybe it is being inlined)
findMostSignificantNeighbor()
of which
java.util.stream.IntPipeline.findFirst()
, .filter()
and java.util.stream.IntStream.range()
are the main culprits (longhand array logic could be much faster & more readable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The multithreaded version is not appreciably faster and maybe slower than a single threaded version, which suggests a problem with the multithreading logic (e.g. way too much synchronisation). This is the CPU trace of my single-threaded version at 64be042
Interestingly, profiling reveals that a full second (≃ 10%) is spent determining whether the image is binary or not with org.bonej.utilities.isColorsBinary()
(it spends all the time in HashSet.add()
). The rest of the time (≃ 80%) is in getAtLocation()
, which leans heavily on imglib2's RandomAccess
. I wonder if there is a more efficient way to get pixel values, and to determine binary-ness?
private boolean getAtLocation(final RandomAccess<B> access, final long x, final long y, final long z) {
access.setPosition(x, 0);
access.setPosition(y, 1);
access.setPosition(z, 2);
return access.get().get();
}
Is a Stream here as efficient as low level ifs and arrays?