Skip to content

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 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
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.

Looks OK to me.

@mbien mbien removed the ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) label Jul 17, 2025
@mbien
Copy link
Member Author

mbien commented Jul 17, 2025

thanks for review, going to rebase before merge

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 force-pushed the optimize-used-in-package branch from 1b6f8e1 to 5036d27 Compare July 17, 2025 17:58
@mbien
Copy link
Member Author

mbien commented Jul 17, 2025

good that I rebased, this is a rare case where merging an old PR can break the build - will fix, seems to be just an import. (diff)

@mbien mbien force-pushed the optimize-used-in-package branch from 5036d27 to be53d35 Compare July 17, 2025 18:18
@mbien mbien merged commit db244c2 into apache:master Jul 17, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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