-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Specialize Bytes
on StdinLock<'_>
#120053
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @m-ou-se (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Bytes
on StdinLock<'_>
Bytes
on StdinLock<'_>
@bors r+ |
…ytes, r=the8472 Specialize `Bytes` on `StdinLock<'_>` I noticed recently, while profiling a little project, that I was spending a lot of time reading from stdin (even with locking). I was using the `.bytes()` iterator adaptor; I figured, since `StdinLock` is a `BufReader` internally, it would work just as fast. But this is not the case, as `Bytes` is only specialized for the raw `BufReader`, and not the `StdinLock`/`MutexGuard` wrapper. Performance improved significantly when I wrapped the lock in a new `BufReader`, but I was still a bit sore about the double buffer indirection. This PR attempts to specialize it, by simply calling the already specialized implementation on `BufReader`.
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#107464 (Add `str::Lines::remainder`) - rust-lang#118803 (Add the `min_exhaustive_patterns` feature gate) - rust-lang#119466 (Initial implementation of `str::from_raw_parts[_mut]`) - rust-lang#120053 (Specialize `Bytes` on `StdinLock<'_>`) - rust-lang#120124 (Split assembly tests for ELF and MachO) - rust-lang#120204 (Builtin macros effectively have implicit #[collapse_debuginfo(yes)]) - rust-lang#120322 (Don't manually resolve async closures in `rustc_resolve`) - rust-lang#120356 (Fix broken markdown in csky-unknown-linux-gnuabiv2.md) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#107464 (Add `str::Lines::remainder`) - rust-lang#118803 (Add the `min_exhaustive_patterns` feature gate) - rust-lang#119466 (Initial implementation of `str::from_raw_parts[_mut]`) - rust-lang#120053 (Specialize `Bytes` on `StdinLock<'_>`) - rust-lang#120124 (Split assembly tests for ELF and MachO) - rust-lang#120204 (Builtin macros effectively have implicit #[collapse_debuginfo(yes)]) - rust-lang#120322 (Don't manually resolve async closures in `rustc_resolve`) - rust-lang#120356 (Fix broken markdown in csky-unknown-linux-gnuabiv2.md) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120053 - AldanTanneo:specialize-stdinlock-bytes, r=the8472 Specialize `Bytes` on `StdinLock<'_>` I noticed recently, while profiling a little project, that I was spending a lot of time reading from stdin (even with locking). I was using the `.bytes()` iterator adaptor; I figured, since `StdinLock` is a `BufReader` internally, it would work just as fast. But this is not the case, as `Bytes` is only specialized for the raw `BufReader`, and not the `StdinLock`/`MutexGuard` wrapper. Performance improved significantly when I wrapped the lock in a new `BufReader`, but I was still a bit sore about the double buffer indirection. This PR attempts to specialize it, by simply calling the already specialized implementation on `BufReader`.
I noticed recently, while profiling a little project, that I was spending a lot of time reading from stdin (even with locking). I was using the
.bytes()
iterator adaptor; I figured, sinceStdinLock
is aBufReader
internally, it would work just as fast. But this is not the case, asBytes
is only specialized for the rawBufReader
, and not theStdinLock
/MutexGuard
wrapper. Performance improved significantly when I wrapped the lock in a newBufReader
, but I was still a bit sore about the double buffer indirection.This PR attempts to specialize it, by simply calling the already specialized implementation on
BufReader
.