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
Refactored header name matching for WASM target #324
Conversation
Hi, thanks for the work. Would it be possible to include benchmarks for parsing header names? Probably could add a bench parsing each one + some common unknown header names. It would be interesting to compare the before and after. |
I tried to make it work in nightly and beta, but then it broke for rust 1.20. The existing benches are pretty much the same, for example: New: Old: I'll some benches just for the name parsing.. |
I don't know how to bench unless it's running rust nightly (cargo bench) - so I had to make it work in nightly to get the numbers. It seems pretty close:
old macro styletest header_name_bad ... bench: 15 ns/iter (+/- 0) new giant match statementtest header_name_bad ... bench: 20 ns/iter (+/- 1) |
I've moved the make_all_known_headers out of the iterator. Sorry for not noticing that. This commit is definitely slowing the code down by about 6% on my laptop :( New bench mark resultsOld code:test header_name_bad ... bench: 15 ns/iter (+/- 11) New code:test header_name_bad ... bench: 20 ns/iter (+/- 0) The main reason for this commit is so we can use When debug building, those macros that expand out to Here's the issue in |
145c2c5
to
a90e78a
Compare
Latest bench mark resultsOld macro based code:
New giant match statement code:
|
We should definitely get this working with wasm. Perhaps there is a way to conditional compile a different fn in wasm? |
This version uses conditional compilation. It'll only compile the wasm version if there are 'debug_assertions' and the target is 'wasm32'. It make the code longer, and harder to maintain though, because now if you add a new header, you'll have to add it in two places. I think simplifying the code to the giant match statement is best. Although 8 more nanoseconds per header check may seem a lot; in msecs it is 8e-6 (0.0000008 msecs). But I'll leave the decision in your capable hands. I tested it and it works in my wasm app in debug mode :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for testing out all the tiny tweaks!
Advantages:
Local count too large yewstack/yew#478
(Un?)fortunately I also ran rustfmt on it - which changed the layouts for the tables a bit but not hideously.