-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parser performance optimizations (#1119)
This PR contains two optimizations: 1. Replaces `TextIndex` as the position tracking structure for the parser context and instead uses the byte offset stored in a `usize`. Most of the time, the other fields computed in `TextIndex` (ie. line, column and UTF-16 offsets) are not used, and they are expensive to compute. Instead, for the very few cases where the `TextIndex` is required, this is computed for the given byte offset. This brings a 39% reduction on instructions/cycles for the parser benchmark. ``` iai::benchmarks::parser Instructions: 2828523499|4666216487 (-39.3829%) [-1.64970x] L1 Hits: 4140897324|6755778229 (-38.7058%) [-1.63148x] L2 Hits: 3784868|3630727 (+4.24546%) [+1.04245x] RAM Hits: 67508|67774 (-0.39248%) [-1.00394x] Total read+write: 4144749700|6759476730 (-38.6824%) [-1.63085x] Estimated Cycles: 4162184444|6776303954 (-38.5774%) [-1.62806x] ``` 2. Caches the parsed leading trivia to avoid having to repeatedly re-parse it when backtracking. This reduces by a further 72% the number of instructions/cycles in the parser benchmark. ``` iai::benchmarks::parser Instructions: 772093852|2828523499 (-72.7033%) [-3.66345x] L1 Hits: 1131017179|4140897324 (-72.6867%) [-3.66122x] L2 Hits: 2047519|3784868 (-45.9025%) [-1.84851x] RAM Hits: 67411|67508 (-0.14369%) [-1.00144x] Total read+write: 1133132109|4144749700 (-72.6610%) [-3.65778x] Estimated Cycles: 1143614159|4162184444 (-72.5237%) [-3.63950x] ``` Overall, the number of estimated instructions went from 4,666,216,487 to 772,093,852 for a reduction of 83% (6x smaller).
- Loading branch information
Showing
21 changed files
with
273 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/generated/parser.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
crates/solidity/outputs/cargo/slang_solidity/src/generated/parser/lexer/mod.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...olidity/outputs/cargo/slang_solidity/src/generated/parser/parser_support/choice_helper.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.