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

Cache hbsPosFor(offset) in Source #1345

Closed

Conversation

chriskrycho
Copy link
Contributor

hbsPosFor is currently the hottest path in the current implementation of the template compiler in terms of self time. Adding this cache for it improves throughput by about half a second in one rough benchmark (against a collection of about 1,500 templates totaling about 54,000 lines of Handlebars), run 5 times against each version of the compiler:

variant average min max
@glimmer/[email protected] 7002.2 6976 7031
@glimmer/compiler@master 9181.4 9159 9202
@glimmer/compiler@experiment 8445.2 8400 8507

Additionally, hbsPosFor stops being the largest self time; in the same rough benchmark, it dropped from ~560ms to ~97ms of self time.

`hbsPosFor` is currently the hottest path in the current implementation
of the template compiler in terms of self time. Adding this cache for
it improves throughput by about half a second in one rough benchmark
(against a collection of about 1,500 templates totaling about 54,000
lines of Handlebars), run 5 times against each version of the
compiler:

|           variant            | average | min  | max  |
| ---------------------------- | ------- | ---- | ---- |
| @glimmer/[email protected]     | 7002.2  | 6976 | 7031 |
| @glimmer/compiler@master     | 9181.4  | 9159 | 9202 |
| @glimmer/compiler@experiment | 8445.2  | 8400 | 8507 |

Additionally, `hbsPosFor` *stops* being the largest self time; in the
same rough benchmark, it dropped from ~560ms to ~97ms of self time.
@chriskrycho
Copy link
Contributor Author

chriskrycho commented Oct 1, 2021

Note: it appears we should probably pick #1344 over this, and not land both, because that one subsumes this one. (Runtimes here are lower than in the table above because I switched to running the benchmark in sequence to avoid CPU contention interfering. That was also the cause of the wild swings observed back in #1341.)

syntax-cache-head (#1344)

variant average min max
@glimmer/[email protected] 2339.2 2306 2362
@glimmer/compiler@master 3700.4 3680 3739
@glimmer/compiler@experiment 3052.8 3028 3082

syntax-cache-hbsPos (#1345, this PR)

variant average min max
@glimmer/[email protected] 2381.2 2328 2483
@glimmer/compiler@master 3750.6 3674 3939
@glimmer/compiler@experiment 3156.6 3137 3200

combined

variant average min max
@glimmer/[email protected] 2326.6 2320 2333
@glimmer/compiler@master 3710 3692 3742
@glimmer/compiler@experiment 3040.4 3002 3064

@chriskrycho chriskrycho closed this Oct 1, 2021
@chriskrycho chriskrycho deleted the syntax-cache-hbsPos branch October 1, 2021 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant