-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change improves performance about 30% by skipping object comparison of `Lrama::Lexer::Token`. `Lrama::Grammar::Symbol` is an unique object then it's ok to use comparison methods inherited from `Object`. ## Execution time ### Before ``` $ time bundle exec exe/lrama --trace=time -o parse.tmp.c --header=parse.tmp.h tmp/parse.tmp.y parse 0.71535 s compute_lr0_states 0.30997 s compute_direct_read_sets 0.03551 s compute_reads_relation 0.00628 s compute_read_sets 0.01906 s compute_includes_relation 0.38075 s compute_lookback_relation 0.76338 s compute_follow_sets 0.05411 s compute_look_ahead_sets 0.55136 s compute_conflicts 0.03092 s compute_default_reduction 0.00360 s compute_yydefact 0.04675 s compute_yydefgoto 0.01515 s sort_actions 0.00385 s compute_packed_table 0.30613 s render 0.06041 s bundle exec exe/lrama --trace=time -o parse.tmp.c --header=parse.tmp.h 3.25s user 0.27s system 99% cpu 3.547 total ``` ### After ``` $ time bundle exec exe/lrama --trace=time -o parse.tmp.c --header=parse.tmp.h tmp/parse.tmp.y parse 0.71531 s compute_lr0_states 0.25773 s compute_direct_read_sets 0.03871 s compute_reads_relation 0.00700 s compute_read_sets 0.01984 s compute_includes_relation 0.12310 s compute_lookback_relation 0.22113 s compute_follow_sets 0.05297 s compute_look_ahead_sets 0.54991 s compute_conflicts 0.00445 s compute_default_reduction 0.00185 s compute_yydefact 0.04470 s compute_yydefgoto 0.00451 s sort_actions 0.00378 s compute_packed_table 0.30478 s render 0.06135 s bundle exec exe/lrama --trace=time -o parse.tmp.c --header=parse.tmp.h 2.36s user 0.27s system 99% cpu 2.660 total ``` ## stackprof ### Before ``` $ stackprof tmp/stackprof-cpu-myapp_before.dump --text --limit 10 ================================== Mode: cpu(1000) Samples: 1749 (0.00% miss rate) GC: 710 (40.59%) ================================== TOTAL (pct) SAMPLES (pct) FRAME 560 (32.0%) 560 (32.0%) (sweeping) 203 (11.6%) 203 (11.6%) Lrama::Lexer#lex_c_code 79 (4.5%) 79 (4.5%) (marking) 74 (4.2%) 74 (4.2%) Lrama::Lexer::Token#== 130 (7.4%) 71 (4.1%) Struct#== 710 (40.6%) 71 (4.1%) (garbage collection) 119 (6.8%) 56 (3.2%) Lrama::States#setup_state 69 (3.9%) 46 (2.6%) Lrama::Context#compute_packed_table 47 (2.7%) 46 (2.6%) Lrama::Lexer#lex_token 730 (41.7%) 40 (2.3%) Array#each ``` ### After ``` stackprof tmp/stackprof-cpu-myapp.dump --text --limit 10 ================================== Mode: cpu(1000) Samples: 1506 (0.00% miss rate) GC: 713 (47.34%) ================================== TOTAL (pct) SAMPLES (pct) FRAME 570 (37.8%) 570 (37.8%) (sweeping) 208 (13.8%) 206 (13.7%) Lrama::Lexer#lex_c_code 79 (5.2%) 79 (5.2%) (marking) 713 (47.3%) 64 (4.2%) (garbage collection) 74 (4.9%) 57 (3.8%) Lrama::Context#compute_packed_table 98 (6.5%) 47 (3.1%) Lrama::States#setup_state 44 (2.9%) 42 (2.8%) Lrama::Lexer#lex_token 67 (4.4%) 39 (2.6%) Lrama::States#compute_includes_relation 58 (3.9%) 39 (2.6%) Lrama::State#transition 500 (33.2%) 39 (2.6%) Array#each ```
- Loading branch information
Showing
5 changed files
with
141 additions
and
20 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