Skip to content

Conversation

@mbien
Copy link
Member

@mbien mbien commented Apr 13, 2025

Some hints are invoked very frequently by the scanner (analog to an inner loop). Querying Preferences from hot code can be expensive.

Preferences were also used outside of the hint implementation, for example for isEnabled() or getSeverity() queries before invoking the actual hint. This isn't visible in the hint metrics log.

Caching Preferences in the hint context covers both usages. The cache is disposed together with the hint processing task.

pink sections mark Preferences queries during hint computation.

image

with cache enabled they are gone
image

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) performance hints ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Apr 13, 2025
@mbien mbien added this to the NB26 milestone Apr 13, 2025
@mbien mbien requested a review from lahodaj April 13, 2025 01:29
@mbien mbien force-pushed the java-hints-preferences-cache branch 2 times, most recently from c775f65 to 3d5f914 Compare April 13, 2025 04:41
@mbien mbien removed this from the NB26 milestone Apr 14, 2025
@mbien
Copy link
Member Author

mbien commented Apr 14, 2025

although this seems to work fine, this is not as clean as it could be IMO. Low level code like hints could ideally have an immutable copy of the hint settings, instead of having to query mutable configuration directly.

Some hints are invoked very frequently by the scanner (analog to an
inner loop). Querying Preferences from hot code can be expensive.

Preferences were also used outside of the hint implementations, for
example for isEnabled() or getSeverity() queries before invoking the
actual hint. This isn't visible in the hint metrics log.

Caching Preferences in the hint context covers both usages. The cache
is disposed together with the hint processing task.
@mbien mbien force-pushed the java-hints-preferences-cache branch from 3d5f914 to 872a144 Compare April 15, 2025 04:01
@mbien mbien added this to the NB26 milestone Apr 15, 2025
Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Seems sensible.

@mbien mbien merged commit 6839d6c into apache:master Apr 15, 2025
36 checks passed
@mbien mbien mentioned this pull request Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) hints Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants