Skip to content

Performance improvement in annotation lookup - #848

Closed
testn wants to merge 1 commit into
testng-team:masterfrom
testn:annotation-perf
Closed

Performance improvement in annotation lookup#848
testn wants to merge 1 commit into
testng-team:masterfrom
testn:annotation-perf

Conversation

@testn

@testn testn commented Nov 1, 2015

Copy link
Copy Markdown
Contributor
  • Annotation performs deep equals and hashCode. Wrapping it with AnnotationWrapper to use System.identityHashCode and == makes it significantly faster especially tests with a large number of data providers like the issues in Severe thread contention while running large test with parallel methods #772
  • Add NULL_MARKER to mark when a method does not have the annotation. It will save the lookup in such case.

@juherr

juherr commented Nov 1, 2015

Copy link
Copy Markdown
Member

Do you have any tests or benchmarks to share?

@testn

testn commented Nov 1, 2015

Copy link
Copy Markdown
Contributor Author

I ran a cutdown version of #772 by changing it to 6,000 data providers. It seems to reduce the test time by 6 seconds.

@juherr

juherr commented Nov 1, 2015

Copy link
Copy Markdown
Member

If the test only takes 6sec, I think you can add it :)

@testn

testn commented Nov 1, 2015

Copy link
Copy Markdown
Contributor Author

Well... what it cuts down is the time it takes to initialize the tests which take much more than the test time itself!

@juherr

juherr commented Nov 1, 2015

Copy link
Copy Markdown
Member

Ok, but you can share it even if it won't be run in the suite each time.
I think it is important to have something to check the fix now and something to check perf regressions later.

@testn

testn commented Nov 1, 2015

Copy link
Copy Markdown
Contributor Author

That's fine. It does not change the behavior. This is just to improve the caching behavior in JDK15AnnotationFinder without changing anything else.

@juherr juherr added the perf label Nov 1, 2015
@testn
testn requested review from juherr and krmahadevan as code owners June 14, 2021 21:43
@juherr juherr added performance Performance-related (combinable with any Type) and removed perf/enhancement labels Jun 20, 2026
@juherr

juherr commented Aug 27, 2026

Copy link
Copy Markdown
Member

Closing this PR as obsolete.

JDK15AnnotationFinder no longer uses Pair<Annotation, ?> directly as the annotation-cache key, so the AnnotationWrapper optimization proposed here no longer applies. The related #772 contention issue was separately fixed by #1305.

Thanks for the original investigation and proposal.

@juherr juherr closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance-related (combinable with any Type)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants