netbeans
netbeans copied to clipboard
org.netbeans.modules.java.hints.bugs.Unused doesn't cancel properly
based on delivery for the slim chance that this gets a review
- streams are not very good at canceling
- by using a plain loop we can simply break out of it
- further:
findUnusedis actually very fast,convertUnusedis the slow part and wasn't cancelable before, the original code might have worked iffindUnusedreturned a stream instead of a list and everything would be one pipeline (this would make the fix more complicated)
issue:
- a synthetic file with 10k fields pins a thread for about 20s at 100%
- most editor features don't work during that time, e.g completion
- hint is enabled by default
discussion:
noticed this while benchmarking other issues (#4500)
#3886 mentioned the poor performance of org.netbeans.modules.java.hints.bugs.Unused and also that it isn't cancelable.
#4204 attempted to fix some of it, however I am not so sure that this worked.
test: FieldsOfJoy10k_Unused_hint.java.txt
scroll down to:
// hints -> probable bugs -> unused element
// org.netbeans.modules.java.hints.bugs.Unused#unused
private void something() {
this. // code change triggers hint and pins cpu to 100%,
// this blocks completion etc. does cancel work?
}
Unused#convertUnused / JavaFixUtilities#safelyRemoveFromParent use most of the time and they were not cancelable.

@jlahoda thanks for review on such short notice!