Skip to content

Only reset the visitedNodes if they are not empty#1646

Open
wmdietl wants to merge 1 commit intomasterfrom
resetifempty
Open

Only reset the visitedNodes if they are not empty#1646
wmdietl wants to merge 1 commit intomasterfrom
resetifempty

Conversation

@wmdietl
Copy link
Copy Markdown
Member

@wmdietl wmdietl commented Apr 21, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 21, 2026 01:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts AnnotatedTypeScanner.reset() to avoid reinitializing the visitedNodes IdentityHashMap when it is already empty, reducing unnecessary allocations during scans that don’t record any visited nodes.

Changes:

  • Only reassigns visitedNodes to a new IdentityHashMap when the current map is non-empty.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 174 to +179
// Instead of re-using the same visitedNodes instance and clear-ing it, profiling showed it
// to be more efficient to create a new instance.
// visitedNodes.clear();
visitedNodes = new IdentityHashMap<>();
if (!visitedNodes.isEmpty()) {
visitedNodes = new IdentityHashMap<>();
}
Copy link

Copilot AI Apr 21, 2026

Choose a reason for hiding this comment

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

The comment above reset() says profiling showed it is more efficient to create a new visitedNodes instance, but the new logic only does so when the map is non-empty. Please update the comment to reflect the conditional behavior (or adjust the code to match the comment), otherwise it becomes misleading for future maintainers.

Copilot uses AI. Check for mistakes.
@wmdietl
Copy link
Copy Markdown
Member Author

wmdietl commented Apr 21, 2026

@copilot Can you measure whether this has any performance benefit compared to CI running on master?

Copy link
Copy Markdown

Copilot AI commented Apr 21, 2026

@copilot Can you measure whether this has any performance benefit compared to CI running on master?

Measured this. For CI tests on master, the last 20 completed runs range from ~64 to 175 minutes (mean ~93 min), so normal CI variance is very large. The run for this PR commit e86abc8 is still queued, so there is not yet a direct CI runtime comparison for this branch. I also ran a focused microbenchmark of the reset() behavior: when visitedNodes is empty, the new logic is ~95–97% faster for that operation; when non-empty, performance is effectively the same (within noise, about ±2%). Given the tiny per-call savings, I would not expect a measurable end-to-end CI time difference against master.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • central.sonatype.com
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx2g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14.4-bin/92wwslzcyst3phie3o264zltu/gradle-8.14.4/lib/gradle-daemon-main-8.14.4.jar (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants