-
Notifications
You must be signed in to change notification settings - Fork 594
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
[Erlang] sublime-syntax format version 2 #2464
Conversation
This commit ... 1. sorts header contexts 2. replaces `pop: true` by `pop: 1` 3. removes obsolete lookahead patterns which have been used to maintain meta scope boundaries before.
This commit converts anonymous contexts into named contexts and uses those in all multi-push and multi-set statements in order to improve readability. Note: This commit does not introduce functional changes.
This commit... 1. converts anonymous contexts into named contexts and uses those in all multi-push and multi-set statements in order to improve readability. 2. creates a `record-fields-declaration` context, which is used in both - the record declaration preprocessor statement (preproc-record) and - the record instantiation statement. It is to reduce duplicated patterns. Note: This commit does not introduce functional changes.
My hunch is that the primary change in performance you are seeing is a result of properly handling scope names. The old approach to scope names allowed pretty much everything to be pre-computed at syntax compile time. However, this had edge cases with a number of situations. As a result, in a handful of situations, the scope names now have to be resolved at run time during the matches. For the In terms of the general slowdown between 4074 and 4084, beyond the scope name mangling at run time, we now also have to sort matches when there are multiple capture groups, and handful of other small tweaks. Most of the bug fixes were things where the simple/naive/fast approach was wrong, and the correct approach was more computationally expensive. I could definitely see how the run time tweaks could cause significant changes when running over 10k samples. |
Makes sense as the performance drop is nearly the same with all syntaxes I have made benchmarks for. Only my new Java syntax which heavily makes use of branch-points to support case insensitive object types etc. runs quite a bit more slower than before. Just wanted to be sure everything is working as expected and we don't miss something. Most files are small enough, so users might not even notice it. |
Erf, or maybe a useless loop over every named context was added to a hot spot in the lexing engine… 🤦♂️ |
:) |
Funny story, but I removed that debug loop and was getting about 25% better performance… |
* [Erlang] Convert to sublime-syntax version 2 This commit ... 1. sorts header contexts 2. replaces `pop: true` by `pop: 1` 3. removes obsolete lookahead patterns which have been used to maintain meta scope boundaries before. * [Erlang] Remove unnamed contexts from multi-push This commit converts anonymous contexts into named contexts and uses those in all multi-push and multi-set statements in order to improve readability. Note: This commit does not introduce functional changes. * [Erlang] Refactor record contexts This commit... 1. converts anonymous contexts into named contexts and uses those in all multi-push and multi-set statements in order to improve readability. 2. creates a `record-fields-declaration` context, which is used in both - the record declaration preprocessor statement (preproc-record) and - the record instantiation statement. It is to reduce duplicated patterns. Note: This commit does not introduce functional changes. * [Erlang] Refactor fun contexts
This PR updates Erlang.sublime-syntax to version 2.
pop: 1
in favor ofpop: true
Notes:
Benchmarks
The whole design and developement process included benchmarking of different solutions to find the best possible performance for the different sets of rules. The following examples provide an impression of the performance improvements achieved with the new design.
10k binary
10k maps
10k records
10k fun types
10k spec
ErlangOTP files
lib\wx\include\gl.hrl
lib\stdlib\test\re_testoutput1_split_test.erl
lib\xmerl\test\xmerl_sax_std_SUITE.erl
lib\crypto\test\crypto_SUITE.erl
Results
Engine Related Performance
The following table shows how parsing performance slowed down between ST4074 and ST4084 without significant changes to Erlang.sublime-syntax (only some scope name changes).
Performance drops by 23..84% due to recent core changes.
Syntax Definition Related Performance
The following table shows how parsing performance slows down just because of opting in to version 2 and replacing all anonymous by named contexts using ST 4084.
Performance drops by another 25% by this commit.