Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Significant performance drop with numbers in Java #4900

Closed
deathaxe opened this issue Oct 6, 2021 · 6 comments
Closed

Significant performance drop with numbers in Java #4900

deathaxe opened this issue Oct 6, 2021 · 6 comments

Comments

@deathaxe
Copy link
Collaborator

deathaxe commented Oct 6, 2021

Description

I noticed a significant performance drop with Java Rewrite with regards to highlighting numbers.

One of the benchmarking files used to track performance is a syntax_test_perf_numbers.java with 10k lines of following code snippet.

0x1.;
0x.1a2f;
0x1.a2f;
0x1ffp+1023 0x1ffp+_1023_;
0xd.aP-1074 0x_1_f_._a_d_P-_10_74_;
0D + 12345D + 12345D + 12_34_5_D - _12_34_5D - 12a45D;
0F + 12345F + 12345F + 12_34_5_F - _12_34_5F - 12a45F;
1. + 1_. + 1_2. - _1.;
1.D + 1_.D + 1_2.D - _1.D;
1.2 + 1_.2_ + 1_2.3_4 + 1_2_._3_4_ - _1.5;
1.2d + 1_.2_d + 1_2.3_4d + 1_2_._3_4_d - _1.5d;
12e34 + 12e+3_ + 1_2e3_4 + 1_2_e3_4_ + 1_2_e_3_4 + 12e+34 + 12e-34 + 12e+3_4 - _12e34;
12e34f + 12e+3_f + 1_2e3_4f + 1_2_e3_4_f + 1_2_e_3_4f + 12e+34f + 12e-34f + 12e+3_4f - _12e34f;
12.e34 + 12.e+3_ + 1_2.e3_4 + 1_2_.e3_4_ + 1_2_.e_3_4 + 12.e+34 + 12.e-34 + 12.e+3_4 - _12.e34;
12.e34f + 12.e+3_f + 1_2.e3_4f + 1_2_.e3_4_f + 1_2_.e_3_4f + 12.e+34f + 12.e-34f + 12.e+3_4f - _12.e34f;
12.34e56 + 12_.34_e+5_ + 1_2.3_4e5_6 + 1_2_.3_4_e5_6_ + 1_2_._3_4e_5_6 + 12.34e+56 + 12.34e-56 + 12.34e+5_6 - _12.34e+5_6;
12.34e56f + 12_.34_e+5_f + 1_2.3_4e5_6f + 1_2_.3_4_e5_6_f + 1_2_._3_4e_5_6f + 12.34e+56f + 12.34e-56f + 12.34e+5_6f - _12.34e+5_6f;
.2 + .2_ + .3_4 + ._3_4_;
.2d + .2_d + .3_4d + ._3_4_d;
.34e56 + .34_e+5_ + .3_4e5_6 + .3_4_e5_6_ + ._3_4e_5_6 + .34e+56 + .34e-56 + .34e+5_6;
23.45 + 23.45F + 23.45d;
.01 + .02e3+.02e3F;
23.45e67+23.45e+6F+23.45e-67D;
0b101101 + 0b10_11_01 + 0b10_11_01_ + 0b_101101 - 0_b10_1101 + 0b;
0b101101l + 0b10_11_01l + 0b10_11_01_l + 0b_101101l - 0_b10_1101l + 0bl;
0xABCD + 0xAB_CD + 0xAB_CD_ + 0x_AB_CD - 0_xAB_CD - 0x;
0xABCDl + 0xAB_CDl + 0xAB_CD_l + 0x_AB_CDl - 0_xAB_CDl;
07 + 0_ + 0_7 + 07_ + 079 + 079_ + 0_79_ - 0a - 0_a;
07l + 0_l + 0_7l + 07_l + 0792l + 079_2_l - 0al - 0_a_l;
0 + 0L;
12345 + 12_34_5 + 1_____5 + 12_34_5_ - _12_34_5 - 12a45;
12345l + 12345L + 12_34_5_L - _12_34_5L - 12a45L;
123_-_456;

Steps to reproduce

  1. Start ST 4113 in SAFE MODE
  2. Copy content from Java Rewrite PR into Packages
  3. Create a syntax_test_perf_numbers.java and place it in User package
  4. Run Syntax Tests - Performance
  5. Follow step 1 - 4 with ST 4115/4116.

Expected behavior

Same (or better) performance in ST4115 compared to 4113.

Actual behavior

The benchmark shows:

  • 130ms on ST 4113
  • 6.5s on ST 4115

Environment

  • Build: 4115
  • Operating system and version: Windows 11 21H2
@BenjaminSchaaf
Copy link
Member

I can't reproduce this on 4115 or 4116 under Linux. Does it still happen in 4116?

@deathaxe
Copy link
Collaborator Author

deathaxe commented Oct 7, 2021

Yes, it's the same with 4116.

@BenjaminSchaaf BenjaminSchaaf self-assigned this Oct 8, 2021
@deathaxe
Copy link
Collaborator Author

deathaxe commented Oct 9, 2021

Recent investigation revealed the variables context to be the reason for the mensioned slowdown.

If the following line is commented out said benchmark file runs through within 70ms.

https://github.com/deathaxe/sublime-packages/blob/053a2ced694490c6c7fa386177a2f0d5e484e56d/Java/Java.sublime-syntax#L166

Slow down seems to be caused by the commented out branches. As soon as one of them is commented in again, parsing time increases to said value.

  variables:
    - match: (?={{id_first_char}})
      branch_point: variables
      branch:
        - variable-other
        - variable-namespace
        # - variable-qualifier
        - method-call-identifier
        # - lambda-parameter

May be an implementation issue of the syntax definition. Trying to find a hopefully better alternative.

@BenjaminSchaaf
Copy link
Member

It's another branch-related performance problem. I've already got a fix that makes it faster than 4113.

@deathaxe
Copy link
Collaborator Author

deathaxe commented Oct 9, 2021

Cool.

@BenjaminSchaaf
Copy link
Member

Fixed in build 4117.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants