Skip to content

Fix JFR profile summary skip check#15997

Merged
mikemccand merged 2 commits intoapache:mainfrom
iprithv:jfr-profile-summary-skip-check
Apr 30, 2026
Merged

Fix JFR profile summary skip check#15997
mikemccand merged 2 commits intoapache:mainfrom
iprithv:jfr-profile-summary-skip-check

Conversation

@iprithv
Copy link
Copy Markdown
Contributor

@iprithv iprithv commented Apr 29, 2026

Description

fixes #15983 (comment)

showJfrProfileSummary used Test.getState().getDidWork() to decide whether any test task failed. This can be false for skipped/up-to-date/not-selected tasks even when nothing failed, causing the profile summary to be skipped incorrectly.

Used Test.getState().getFailure() == null instead so the profile summary is skipped only when a test task actually failed.

Signed-off-by: prithvi <prithvisivasankar@gmail.com>
@iprithv
Copy link
Copy Markdown
Contributor Author

iprithv commented Apr 29, 2026

don't have permissions to add skip-changelog, please someone help adding. Thanks!

Signed-off-by: prithvi <prithvisivasankar@gmail.com>
@rmuir rmuir added the skip-changelog Apply to PRs that don't need a changelog entry, stopping the automated changelog check. label Apr 30, 2026
Copy link
Copy Markdown
Member

@mikemccand mikemccand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @iprithv! I'll merge soon -- this is a nice discovery of pre-existing issue making -Ptests.profile=true not work (in some cases? maybe on fully clean checkout it'd work?).


private static boolean taskDidNotFail(Test task) {
try {
task.getState().rethrowFailure();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null check was insufficient?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked w/ Gemini (I was worried maybe this method had side effects or so -- it's fine (idempotent)): https://share.google/aimode/keVKF6K1aIoSshuoI

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes @mikemccand. Logically it was enough, but Error Prone flagged getFailure() == null as RedundantNullCheck in build-infra-shadow:compileJava. rethrowFailure() avoids that and keeps the same intent. Thanks for checking it is idempotent!

@mikemccand mikemccand merged commit 6b86bfe into apache:main Apr 30, 2026
13 of 14 checks passed
@mikemccand
Copy link
Copy Markdown
Member

I'll backport both changes to 10.x.

@mikemccand
Copy link
Copy Markdown
Member

This change worked -- I'm able to simply run profiling:

./gradlew -p lucene/core test -Ptests.profile=true -Ptests.profile.stacksize=8 -Ptests.profile.linenumbers=true

but I still get not-really-loving top CPU stacks:

PROFILE SUMMARY from 155438 events (total: 155438)
  tests.profile.mode=cpu
  tests.profile.count=10
  tests.profile.stacksize=8
  tests.profile.linenumbers=true
PERCENT       CPU SAMPLES   STACK
0.53%         831           java.util.stream.MatchOps$2MatchSink#accept():119 [JIT compiled code]
                              at java.util.stream.Streams$RangeIntSpliterator#tryAdvance():82 [JIT compiled code]
                              at java.util.stream.IntPipeline#forEachWithCancel():163 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#copyIntoWithCancel():588 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#copyInto():574 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#wrapAndCopyInto():560 [JIT compiled code]
                              at java.util.stream.MatchOps$MatchOp#evaluateSequential():230 [Inlined code]
                              at java.util.stream.MatchOps$MatchOp#evaluateSequential():196 [JIT compiled code]
0.31%         489           java.util.stream.Streams$RangeIntSpliterator#tryAdvance():77 [JIT compiled code]
                              at java.util.stream.IntPipeline#forEachWithCancel():163 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#copyIntoWithCancel():588 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#copyInto():574 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#wrapAndCopyInto():560 [JIT compiled code]
                              at java.util.stream.MatchOps$MatchOp#evaluateSequential():230 [Inlined code]
                              at java.util.stream.MatchOps$MatchOp#evaluateSequential():196 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#evaluate():265 [JIT compiled code]
0.31%         485           sun.nio.ch.UnixFileDispatcherImpl#pread0() [Native code]
                              at sun.nio.ch.UnixFileDispatcherImpl#pread():57 [JIT compiled code]
                              at sun.nio.ch.IOUtil#readIntoNativeBuffer():339 [JIT compiled code]
                              at sun.nio.ch.IOUtil#read():307 [JIT compiled code]
                              at sun.nio.ch.IOUtil#read():284 [Inlined code]
                              at sun.nio.ch.FileChannelImpl#readInternal():1198 [JIT compiled code]
                              at sun.nio.ch.FileChannelImpl#implRead():1170 [JIT compiled code]
                              at sun.nio.ch.FileChannelImpl#read():1152 [JIT compiled code]
0.28%         433           java.util.stream.IntPipeline#forEachWithCancel():163 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#copyIntoWithCancel():588 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#copyInto():574 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#wrapAndCopyInto():560 [JIT compiled code]
                              at java.util.stream.MatchOps$MatchOp#evaluateSequential():230 [Inlined code]
                              at java.util.stream.MatchOps$MatchOp#evaluateSequential():196 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#evaluate():265 [JIT compiled code]
                              at java.util.stream.IntPipeline#noneMatch():549 [Inlined code]

What is so heavily using java.util.stream.* in our core unit tests .... lemme make stack size bigger.

@mikemccand
Copy link
Copy Markdown
Member

OK nevermind if I lower the stack size, the profiling looks more reasonable -- I think it's working! -- I'm kinda happy that Random#next is up there (number 2) -- go randomized testing!

> Task :showJfrProfileSummary
Aggregated summary of 12 jfr profiles.
PROFILE SUMMARY from 158249 events (total: 158249)
  tests.profile.mode=cpu
  tests.profile.count=100
  tests.profile.stacksize=2
  tests.profile.linenumbers=true
PERCENT       CPU SAMPLES   STACK
0.56%         882           java.lang.AbstractStringBuilder#append():653 [JIT compiled code]
                              at java.lang.StringBuilder#append():179 [Inlined code]
0.54%         855           java.util.concurrent.atomic.AtomicLong#compareAndSet():138 [Inlined code]
                              at java.util.Random#next():438 [JIT compiled code]
0.51%         810           org.apache.lucene.tests.store.MockIndexOutputWrapper#writeBytes():149 [JIT compiled code]
                              at org.apache.lucene.tests.store.MockIndexOutputWrapper#writeByte():131 [JIT compiled code]
0.49%         780           org.apache.lucene.tests.store.MockDirectoryWrapper#maybeThrowDeterministicException():1074 [JIT compiled code]
                              at org.apache.lucene.tests.store.MockIndexOutputWrapper#writeBytes():149 [JIT compiled code]
0.49%         774           org.apache.lucene.util.FixedBitSet#<init>():148 [Inlined code]
                              at org.apache.lucene.codecs.lucene104.Lucene104PostingsReader$BlockPostingsEnum#<init>():306 [JIT compiled code]
0.47%         746           jdk.internal.misc.Unsafe#allocateUninitializedArray0():1403 [JIT compiled code]
                              at jdk.internal.misc.Unsafe#allocateUninitializedArray():1396 [JIT compiled code]
0.47%         737           java.util.stream.MatchOps$2MatchSink#accept():119 [JIT compiled code]
                              at java.util.stream.Streams$RangeIntSpliterator#tryAdvance():82 [JIT compiled code]
0.46%         723           java.util.Arrays#copyOf():3537 [Inlined code]
                              at java.lang.AbstractStringBuilder#ensureCapacityNewCoder():282 [JIT compiled code]
0.42%         659           org.apache.lucene.codecs.lucene104.Lucene104PostingsReader$BlockPostingsEnum#<init>():334 [JIT compiled code]
                              at org.apache.lucene.codecs.lucene104.Lucene104PostingsReader#postings():259 [JIT compiled code]
0.41%         644           java.util.concurrent.locks.AbstractQueuedSynchronizer#setState():555 [Inlined code]
                              at java.util.concurrent.locks.ReentrantLock$Sync#tryRelease():180 [JIT compiled code]
0.38%         602           org.apache.lucene.geo.TestTessellator#isEdgeFromPolygon():1060 [JIT compiled code]
                              at org.apache.lucene.geo.TestTessellator#checkTriangleEdgesFromPolygon():1056 [JIT compiled code]
0.37%         583           com.carrotsearch.randomizedtesting.RandomizedContext#context():239 [JIT compiled code]
                              at com.carrotsearch.randomizedtesting.RandomizedContext#current():134 [Inlined code]
0.36%         572           org.apache.lucene.geo.TestTessellator#isEdgeFromPolygon():1061 [JIT compiled code]
                              at org.apache.lucene.geo.TestTessellator#checkTriangleEdgesFromPolygon():1056 [JIT compiled code]
0.35%         554           java.nio.HeapByteBuffer#get():180 [JIT compiled code]
                              at org.apache.lucene.store.ByteBuffersDataInput#readByte():97 [JIT compiled code]
0.34%         542           java.nio.ByteBuffer#limit():1575 [JIT compiled code]
                              at java.nio.ByteBuffer#limit():292 [JIT compiled code]
0.32%         509           java.util.zip.Inflater#inflateBytesBytes() [Native code]
                              at java.util.zip.Inflater#inflate():354 [JIT compiled code]
0.30%         475           java.nio.ByteBuffer#position():1561 [Inlined code]
                              at java.nio.HeapByteBuffer#get():196 [JIT compiled code]
0.29%         465           org.apache.lucene.geo.TestTessellator#isEdgeFromPolygon():1060 [JIT compiled code]
                              at org.apache.lucene.geo.TestTessellator#checkTriangleEdgesFromPolygon():1053 [JIT compiled code]
0.29%         464           org.apache.lucene.index.IndexingChain$IntBlockAllocator#getIntBlock():1487 [Inlined code]
                              at org.apache.lucene.util.IntBlockPool#nextBuffer():153 [JIT compiled code]
0.29%         463           java.lang.Thread#yield0() [Native code]
                              at java.lang.Thread#yield():462 [Inlined code]
0.29%         461           org.apache.lucene.geo.TestTessellator#isEdgeFromPolygon():1061 [JIT compiled code]
                              at org.apache.lucene.geo.TestTessellator#checkTriangleEdgesFromPolygon():1050 [JIT compiled code]
0.29%         457           java.util.stream.IntPipeline#forEachWithCancel():163 [JIT compiled code]
                              at java.util.stream.AbstractPipeline#copyIntoWithCancel():588 [JIT compiled code]
0.29%         455           org.apache.lucene.util.ByteBlockPool$DirectTrackingAllocator#getByteBlock():97 [JIT compiled code]
                              at org.apache.lucene.util.ByteBlockPool#nextBuffer():196 [JIT compiled code]
0.28%         443           org.apache.lucene.geo.TestTessellator#isEdgeFromPolygon():1060 [JIT compiled code]
                              at org.apache.lucene.geo.TestTessellator#checkTriangleEdgesFromPolygon():1050 [JIT compiled code]
0.28%         441           org.apache.lucene.geo.TestTessellator#isEdgeFromPolygon():1061 [JIT compiled code]
                              at org.apache.lucene.geo.TestTessellator#checkTriangleEdgesFromPolygon():1053 [JIT compiled code]
0.27%         425           com.carrotsearch.randomizedtesting.RandomizedContext#current():134 [Inlined code]
                              at org.apache.lucene.tests.util.LuceneTestCase#lambda$static$0():736 [Inlined code]
0.27%         422           sun.nio.fs.UnixNativeDispatcher#open0() [Native code]
                              at sun.nio.fs.UnixNativeDispatcher#open():69 [JIT compiled code]

@mikemccand
Copy link
Copy Markdown
Member

I'll backport both changes to 10.x.

Hmm actually this is tricky -- in 10.x the profiling gradle integration is different (in gradle/testing/profiling.gradle Groovy script, instead of CodeProfilingPlugin.java in main). I'm not sure how to backport/port to Groovy (the conditional logic to pick CPU Time profiler on Linux).

sgup432 pushed a commit to sgup432/lucene that referenced this pull request May 4, 2026
* Fix JFR profile summary skip check

Signed-off-by: prithvi <prithvisivasankar@gmail.com>

* Fix JFR profile summary skip check

Signed-off-by: prithvi <prithvisivasankar@gmail.com>

---------

Signed-off-by: prithvi <prithvisivasankar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:build-infra skip-changelog Apply to PRs that don't need a changelog entry, stopping the automated changelog check.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants