Skip to content

Conversation

@mbien
Copy link
Member

@mbien mbien commented Apr 21, 2025

  • optimizes the isUnusedInPkg() code path
  • one pkg private element comes rarely alone, getting the ClassIndex for the FileObject can be expensive
  • compute it only once

running a synthetic test file with 10k package private elements

findUnused() without caching (in ms):

time: 8289
time: 9288

ClassIndex computed once:

time: 262
time: 1818

note: the method is called twice on first file open, both measurements are shown since the code paths are different.

This might be potentially solvable without putting anything into the cache and making UnusedDetector an instance object.

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) performance labels Apr 21, 2025
@mbien mbien added this to the NB27 milestone Apr 21, 2025
@mbien mbien force-pushed the unused-pkgprivate-performance branch from 68072fe to 97686fc Compare April 21, 2025 14:38
@mbien mbien changed the title Cache ClassIndex during unused detector search Cache ClassIndex during UnusedDetector search Apr 23, 2025
@mbien mbien marked this pull request as ready for review April 30, 2025 18:39
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 good to me, with some suggestions inline.

@mbien mbien force-pushed the unused-pkgprivate-performance branch from 97686fc to 3fcc547 Compare May 6, 2025 04:31
@mbien
Copy link
Member Author

mbien commented May 6, 2025

the key is now a constant and changed the retention policy from ON_TASK_END to ON_CHANGE to be the same as the other cache usage in this class (tested it too).

 - optimizes the isUnusedInPkg() code path
 - one pkg private element comes rarely alone, getting the ClassIndex
   for the FileObject can be expensive
 - compute it only once
@mbien
Copy link
Member Author

mbien commented May 7, 2025

going to rebase and then merge once green since RC3 was synced. Thanks for the review!

@mbien mbien force-pushed the unused-pkgprivate-performance branch from 3fcc547 to 9bacf23 Compare May 7, 2025 22:58
@mbien mbien merged commit 5780a4c into apache:master May 7, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Editor 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