-
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
Implement Chain with Option fuses #70896
Conversation
The iterators are now "fused" with `Option` so we don't need separate state to track which part is already exhausted, and we may also get niche layout for `None`. We don't use the real `Fuse` adapter because its specialization for `FusedIterator` unconditionally descends into the iterator, and that could be expensive to keep revisiting stuff like nested chains. It also hurts compiler performance to add more iterator layers to `Chain`.
@bors try @rust-timer queue Locally, I measure this being a little faster than nightly on @KrishnaSannasi I went ahead and tried your folding idea for |
Awaiting bors try build completion |
⌛ Trying commit 859b8da with merge 1f6bcab4a99b6f10ce766a1fe581010d3dd68f6a... |
☀️ Try build successful - checks-azure |
Queued 1f6bcab4a99b6f10ce766a1fe581010d3dd68f6a with parent 42abbd8, future comparison URL. |
Finished benchmarking try commit 1f6bcab4a99b6f10ce766a1fe581010d3dd68f6a, comparison URL. |
@scottmcm I updated |
That perf report matches my own results -- better on We can also compare to #70332, with the caveat that they're not on the exact same merge base, but this PR looks a lot better. |
@bors r+
I almost did 🙂 But then I thought about it more and worried that the |
📌 Commit ce8abc6 has been approved by |
Rollup of 7 pull requests Successful merges: - rust-lang#67705 (Use unrolled loop for searching NULL in [u16] on Windows) - rust-lang#70367 (save/restore `pessimistic_yield` when entering bodies) - rust-lang#70822 (Don't lint for self-recursion when the function can diverge) - rust-lang#70868 (rustc_codegen_ssa: Refactor construction of linker arguments) - rust-lang#70896 (Implement Chain with Option fuses) - rust-lang#70916 (Support `#[track_caller]` on functions in `extern "Rust" { ... }`) - rust-lang#70918 (rustc_session: forbid lints override regardless of position) Failed merges: r? @ghost
Changes[1] to the Rust standard library are affecting[2] the nesting size of types to the point where typed-html can not be built on nightly. This resolves the issue by increasing the acceptable recursion depth for the crate. [1]: rust-lang/rust#70896 [1]: rust-lang/rust#71359 Closes: bodil#112
Changes[1] to the Rust standard library are affecting[2] the nesting size of types to the point where typed-html can not be built on nightly. This resolves the issue by increasing the acceptable recursion depth for the crate. [1]: rust-lang/rust#70896 [2]: rust-lang/rust#71359 Closes: bodil#112
IMO that's niche enough to not worry about -- they were using a very long chain, but even that is now resolved by bodil/typed-html#117 (though not published yet). Plus, that project is already rife with increased Also, this PR had an incidental benefit on the very long compilation time in #70749 -- that code now compiles quickly with the |
The iterators are now "fused" with
Option
so we don't need separate state to track which part is already exhausted, and we may also get niche layout forNone
. We don't use the realFuse
adapter because its specialization forFusedIterator
unconditionally descends into the iterator, and that could be expensive to keep revisiting stuff like nested chains. It also hurts compiler performance to add more iterator layers toChain
.This change was inspired by the proposal on the internals forum. This is an alternate to #70332, directly employing some of the same
Fuse
optimizations as #70366 and #70750.r? @scottmcm