searcher: erase reader type R behind &mut dyn io::Read in search_reader - #3518
Open
haydonryan wants to merge 1 commit into
Open
searcher: erase reader type R behind &mut dyn io::Read in search_reader#3518haydonryan wants to merge 1 commit into
haydonryan wants to merge 1 commit into
Conversation
Collapse the R: io::Read monomorphization dimension so the decoder, LineBufferReader and per-line search loop are compiled once per (M, S) instead of once per concrete reader type. Saves ~1.1% release binary (~2% on release-lto) per arch with no runtime regression; public API and all call sites unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm trying to make this year the year we all really focus on reducing binary size while maintaining or improving speed.
I'm working on some AI optimization prompts to help find areas where we can shrink rust binaries. While the majority of the output when I ran it against ripgrep was not relevant, it did find a useful reduction of size.
Rust generics are great, however when they're used against a lot of parameters, rust compiles and embeds in the binary a version of the code for each type. This can add bloat to the binary. By making this a trait object, we don't get as many duplicated versions of the code.
Below here is LLM generated by Deepseek v4 flash 0731 running locally on my personal server. Measurements were performed on a 28vcpu vm running on an Epyc 7443 that is backed by 5xNVME Raid Z1 served by truenas.