Skip to content

Unused in package hint: optimize used-in-package scenario #8524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mbien
Copy link
Member

@mbien mbien commented May 23, 2025

By assuming that most code is used, we can focus on the scenario where an Element is used in a package local file and cache it.

This avoids having to repeatedly scan the package for usage.

The not-used case is not cached, this allows a much simpler impl.

  • main change is in UnusedDetector
  • second commit is for cleanup in SemanticHighlighterBase and related files, some logging improvements

before:

INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 2,431 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:5c29964c
INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 2,709 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:5c29964c
INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 1,913 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:5c29964c
INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 1,967 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:5c29964c
INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 2,530 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:5c29964c

after:

INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 793 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:44f9b9b
INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 412 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:44f9b9b
INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 80 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:44f9b9b
INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 136 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:44f9b9b
INFO [org.netbeans.modules.java.editor.semantic.SemanticHighlighter]: Semantic 78 netbeans/ide/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java@f8531b5d:44f9b9b

test case is RepositoryUpdater.java; each log event is a code modification. Performance improves once caches fill.

mbien added 2 commits May 23, 2025 03:39
By assuming that most code is used, we can focus on the scenario
where an Element is used in a package local file and cache it.

This avoids having to repeatedly scan the package for usage.

The not-used case is not cached, this allows a much simpler impl.
@mbien mbien added this to the NB27 milestone May 23, 2025
@mbien mbien requested review from dbalek and lahodaj May 23, 2025 01:53
@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 May 23, 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.

1 participant