netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

static imported methods slow down auto completion

Open mbien opened this issue 3 years ago • 0 comments

NB 15

This is somewhat related to #4140 (fixed via #4142 / NB 15) but the codepath is different (see flamegraph).

when taking the FieldsOfJoy test as baseline and adding 10k methods to the fields, completion performance suffers significantly (~10s). If the methods are not there, completion finishes instantly thanks to #4142.

However: this is specific to static imports, it can't be reproduced with normal usage

//import static test.fields.FieldsOfJoy10k.*;   // <- this is always fast with NB 15
import static test.fields.FieldsOfJoy10k_many_methods.*;

public class Fields {
    public static void main(String[] args) {
        System.out.println( );  // use completion here, this is slow!
        System.out.println(test.fields.FieldsOfJoy10k_many_methods.);  // this is fast!
    }
}

thanks to @SirIntellegence for discovering this (https://github.com/apache/netbeans/pull/4440#issuecomment-1213492886).

async profiler flamegraph shows that a significant time is spent in JavaCompletionTask.conflictsWithLocal (this isn't the full graph, see attached file below) many_methods

full graph: many_methods.html.txt

mbien avatar Aug 12 '22 22:08 mbien