-
Notifications
You must be signed in to change notification settings - Fork 123
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
Speed up parsing with table-driven predicates. #276
Conversation
When loading a capture in wrench, startup time is dominated by RON parsing, and most of that time is spent in simple byte predicates such as "is this a whitespace byte?" These predicates currently use `slice::contains` to search through a list of possible matching bytes. The list lengths range from 4 to 63. This commit changes these predicates to use a table. Each predicate is now just an array lookup plus a bit mask. This more than doubles the parsing speed for the wrench capture I have been looking at.
f897826
to
27d6989
Compare
I'm happy to see the loading hotpath optimized? Has been staring at WR captures loading for quite a bit :) |
Here's a partial Cachegrind profile before, showing instruction counts:
And after:
I only measured release builds, but this is a simple enough change that I am confident that it would be a significant win on debug builds too. |
This needs to make it into a RON release and then WebRender needs to be updated to use it, of course :) |
The general workflow of getting patches in our projects is - filing a separate PR against the branch of the released version (v0.6 in our case, but you could also do it for v0.5, etc), and adding a commit that bumps the patch version of the crate as well as adds a small changelog entry. Would you be interested in making such a PR? |
Is that a non-standard release model? I admit I don't exactly follow the steps required in your description. I was previously confused as to why the current |
What is the standard release model that you are referring to? |
It seems pretty common for people to just release off trunk. |
Trunk (or Anyhow, this is how we roll. Unless you have a specific reason for us to do it differently, let's keep this model - it proved it self useful (and I'm open to talk more!). |
When loading a capture in wrench, startup time is dominated by RON parsing, and most of that time is spent in simple byte predicates such as "is this a whitespace byte?" These predicates currently use `slice::contains` to search through a list of possible matching bytes. The list lengths range from 4 to 63. This commit changes these predicates to use a table. Each predicate is now just an array lookup plus a bit mask. This more than doubles the parsing speed for the wrench capture I have been looking at.
I ported it to v0.6 manually, it's a part of ron-0.6.2 |
When loading a capture in wrench, startup time is dominated by RON
parsing, and most of that time is spent in simple byte predicates such
as "is this a whitespace byte?"
These predicates currently use
slice::contains
to search through alist of possible matching bytes. The list lengths range from 4 to 63.
This commit changes these predicates to use a table. Each predicate is
now just an array lookup plus a bit mask. This more than doubles the
parsing speed for the wrench capture I have been looking at.