-
Notifications
You must be signed in to change notification settings - Fork 77
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
Prefer inline representation over static? #276
Comments
A very quick benchmark: Before:
After:
I also wonder if reducing the size of the static set (because it no longer contains any strings under 8 bytes) might improve performance for static strings too - but I've not tested that. The change is really simple: src/atom.rs If you don't see a downside to this, would be happy to make a PR (also including necessary changes to the codegen). |
* Benchmarks use longer static strings * Use inline for short strings Closes #276.
Implemented in #278 |
Currently, static representation takes priority over inline.
For example,
Atom::from("bananas")
performs the following operations:If "bananas" is not in the static set, it falls back to inline representation.
Is there a reason why strings of 7 bytes or less don't skip all the above, and go direct to using inline representation?
As far as I can see, inline representation is much cheaper, and which representation takes priority doesn't matter for the rest of Atom's implementation - as long as it's consistent.
Short strings could still be input to the codegen so they can be used in
atom!()
, but codegen would not add them to the static set, and instead generatepack_inline()
calls (instead ofpack_static()
).I can't see any downside to this, and imagine it could be significantly more performant for use cases where there are lots of short strings in use. But am I missing something?
If you think this may be worth looking into, I'd be happy to implement and benchmark.
The text was updated successfully, but these errors were encountered: