eclipse-jdtls / eclipse.jdt.ls

Java language server
1.8k stars 401 forks source link

Improve the perf of JDTUtils.toLocation() #2446

Closed jdneo closed 1 year ago

jdneo commented 1 year ago

We introduced a fancy feature about Lombok support that allows more accurate code navigation and refactoring for the lombok generated methods in https://github.com/eclipse/eclipse.jdt.ls/pull/2339

Recently I found that the change to the JDTUtils.toLocation() might have some impact on the perf when the class has a large number of fields. See the profiling screenshots below:

image

image

Most of the execution time is taken by the newly added getGetter() & getSetter(). It's acceptable when those methods are invoked for code actions since they are triggered manually. While considering that document symbol calculation is a frequent request when user is typing. We might need to improve it.

Steps to reproduce

  1. Add Lombok dependency
  2. Using the following class
    
    import lombok.Data;

@Data public class D { public int a1; public int a2; public int a3; public int a4; public int a5; public int a6; public int a7; public int a8; public int a9; public int a10; public int a11; public int a12; public int a13; public int a14; public int a15; public int a16; public int a17; public int a18; public int a19; public int a20; public int a21; public int a22; public int a23; public int a24; public int a25; public int a26; public int a27; public int a28; public int a29; public int a30; public int a31; public int a32; public int a33; public int a34; public int a35; public int a36; public int a37; public int a38; public int a39; public int a40; public int a41; public int a42; public int a43; public int a44; public int a45; public int a46; public int a47; public int a48; public int a49; public int a50; public int a51; public int a52; public int a53; public int a54; public int a55; public int a56; public int a57; public int a58; public int a59; public int a60; public int a61; public int a62; public int a63; public int a64; public int a65; public int a66; public int a67; public int a68; public int a69; public int a70; public int a71; public int a72; public int a73; public int a74; public int a75; public int a76; public int a77; public int a78; public int a79; public int a80; public int a81; public int a82; public int a83; public int a84; public int a85; public int a86; public int a87; public int a88; public int a89; public int a90; public int a91; public int a92; public int a93; public int a94; public int a95; public int a96; public int a97; public int a98; public int a99; public int a100;

public int b1;
public int b2;
public int b3;
public int b4;
public int b5;
public int b6;
public int b7;
public int b8;
public int b9;
public int b10;
public int b11;
public int b12;
public int b13;
public int b14;
public int b15;
public int b16;
public int b17;
public int b18;
public int b19;
public int b20;
public int b21;
public int b22;
public int b23;
public int b24;
public int b25;
public int b26;
public int b27;
public int b28;
public int b29;
public int b30;
public int b31;
public int b32;
public int b33;
public int b34;
public int b35;
public int b36;
public int b37;
public int b38;
public int b39;
public int b40;
public int b41;
public int b42;
public int b43;
public int b44;
public int b45;
public int b46;
public int b47;
public int b48;
public int b49;
public int b50;
public int b51;
public int b52;
public int b53;
public int b54;
public int b55;
public int b56;
public int b57;
public int b58;
public int b59;
public int b60;
public int b61;
public int b62;
public int b63;
public int b64;
public int b65;
public int b66;
public int b67;
public int b68;
public int b69;
public int b70;
public int b71;
public int b72;
public int b73;
public int b74;
public int b75;
public int b76;
public int b77;
public int b78;
public int b79;
public int b80;
public int b81;
public int b82;
public int b83;
public int b84;
public int b85;
public int b86;
public int b87;
public int b88;
public int b89;
public int b90;
public int b91;
public int b92;
public int b93;
public int b94;
public int b95;
public int b96;
public int b97;
public int b98;
public int b99;
public int b100;

public static void main(String[] args) {

}

}


3. Randomly type something in the main method to invoke some document symbol requests.
jdneo commented 1 year ago

@snjeza Would you like to take a look at this issue?

snjeza commented 1 year ago

@jdneo I will check it.