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

Enable memchr feature by default? #552

Closed
joshtriplett opened this issue Feb 7, 2024 · 5 comments · Fixed by #573
Closed

Enable memchr feature by default? #552

joshtriplett opened this issue Feb 7, 2024 · 5 comments · Fixed by #573

Comments

@joshtriplett
Copy link
Collaborator

Should trillium-routes enable memchr by default for performance, and let people who want to avoid the dependency (and don't already have it elsewhere in their dependency tree) disable default features?

@jbr
Copy link
Contributor

jbr commented Feb 7, 2024

My concern here is less about the dependency (as trillium-http depends on memchr nonoptionally) but uncertainty about whether it represents a performance improvement. I did some benchmarking and it seems to depend on several things, including the path length and whether it can be inlined across crate boundaries, which is something only the application binary can influence with lto=fat. Using memchr represented a slight performance regression when lto=thin, but maybe that's acceptable as the default?

@joshtriplett
Copy link
Collaborator Author

Ah, I see. I would have expected the memchr crate to contain the requisite fast-paths for "this seems short" to avoid the problem of memchrnot paying off for short paths; if you have benchmarks showing cases wherememchris slower than using std, you may want to send them to thememchr` project as a performance issue to tune the heuristics. (Or, potentially, have such heuristics in trillium.)

That aside, inlining across crate boundaries should be possible with an explicit #[inline], even without lto=fat...

@jbr
Copy link
Contributor

jbr commented Feb 9, 2024

That aside, inlining across crate boundaries should be possible with an explicit #[inline], even without lto=fat...

Really? That's great news! Is that related to rust-lang/rust#116505?

@joshtriplett
Copy link
Collaborator Author

@jbr No, that issue is about doing inlining even without #[inline]. Inlining across crates with an explicit #[inline] has been supported for a long time.

@jbr
Copy link
Contributor

jbr commented Feb 13, 2024

I did some more benchmarking and it seems like now I'm getting a slight benefit from memchr, so I'm content to make it the default (or probably just remove the feature, since trillium itself already requires memchr)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants