Skip to content

std::io: Faster BufferedReader:read_byte. #10987

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

Closed
wants to merge 1 commit into from

Conversation

spaolacci
Copy link
Contributor

Replace Reader's default implementation to take benefit of that
particular fixed size / very small reads situation.

Brings a 2x perf improvement on a lightweight wc-like test app (300
iterations, `/usr/share/dict/web2', MBA laptop).

Replace Reader's default implementation to take benefit of that
particular fixed size / very small reads situation.

Brings a 2x perf improvement on a lightweight wc-like test app (300
iterations, `/usr/share/dict/web2', MBA laptop).
@alexcrichton
Copy link
Member

I'm not sure that this is the best way to go about doing this. This makes BufferedReader a little faster, but what about MemReader and BufReader? What about anything implementing the Buffer trait?

I would believe that this is a perf improvement, but I also believe that this needs more thought as to whether it's necessary and if so, how to extend it to code beyond just a buffered reader.

@spaolacci
Copy link
Contributor Author

Thanks for the quick review. It indeed doesn't address MemReader, nor all the Readers at all, but my Rust knowledge is admittedly not large enough to come up with any nicer approach (or just any sane approach maybe).

On one side Reader::read must work with a large range of user-chunk sizes, on the other side there're a few situations (e.g u8, u16, u32, u64) where shortcuts are possible/desirable.

I would however be whiling to explore any lead you may have.

@spaolacci spaolacci closed this Dec 17, 2013
@spaolacci spaolacci deleted the readbyte branch December 17, 2013 12:24
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 14, 2023
new lint: `type_id_on_box`

Closes rust-lang#7687.

A new lint that detects calling `.type_id()` on `Box<dyn Any>` (and not on the underlying `dyn Any`), which can make up for some pretty confusing bugs!

changelog: new lint: [`type_id_on_box`]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants