Uh oh!
There was an error while loading. Please reload this page.
Hides default fns inside Fuse impl to avoid exposing it to any crate - #70910
Conversation
…IteratorImpl to avoid exposing default functions outside of the current crate.
rakshith-ravi
commented
Apr 8, 2020
Oh also, I just submitted this to understand if my logic is correct. In case you think it's good, don't approve / merge yet. I'll add a few comments for others stumbling across this in the future and then it can be merged. Didn't want to do that yet in case my implementation logic was wrong |
Dylan-DPC-zz
commented
Apr 8, 2020
Added WIP to the title so it doesn't get merged, when you are ready you can remove it |
rakshith-ravi
commented
Apr 8, 2020
Cool. Does the WIP mean it won't get reviewed? Cuz I want it to get reviewed before I can make further changes. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
cuviper
commented
Apr 9, 2020
@bors try @rust-timer queue |
rust-timer
commented
Apr 9, 2020
Awaiting bors try build completion |
bors
commented
Apr 9, 2020
⌛ Trying commit 0a54a94 with merge 99ca7e89f078ee57814d4b9c5575f84f2a2d2329... |
bors
commented
Apr 9, 2020
☀️ Try build successful - checks-azure |
rust-timer
commented
Apr 9, 2020
Queued 99ca7e89f078ee57814d4b9c5575f84f2a2d2329 with parent 93dc97a, future comparison URL. |
rust-timer
commented
Apr 10, 2020
Finished benchmarking try commit 99ca7e89f078ee57814d4b9c5575f84f2a2d2329, comparison URL. |
Removed unnecessarry empty impls. Moved code to organise it better
@cuviper a couple of questions:
PS, changes from my side are done. You can merge it away if you think this is good to go |
rakshith-ravi
commented
Apr 14, 2020
@cuviper sorry to bother you again, but did you get a chance to review this PR? |
cuviper
commented
Apr 14, 2020
You could make an iterator that counts how many times structFoo<'a>(&'amutusize);implIteratorforFoo<'_>{typeItem = ();fnnext(&mutself) -> Option<()>{*self.0 += 1;None}}fnmain(){letmut counter = 0;letmut foo = Foo(&mut counter).fuse();for _ in0..10{
foo.next();}dbg!(counter);}This will print impl std::iter::FusedIteratorforFoo<'_>{}Then it will print If you'd like to turn that into explicit tests, with and without
It should be trivially inlined, yes, but that is more work for compilation time -- so I'm not surprised that the perf results show a little bit of a slowdown.
Well, before assembly there's also LLVM IR, so you could stare at that instead. 🙂 But without even bothering at the instruction level, you could just look at what functions are emitted. If there's no explicit function for the new impl layers, then those must have been inlined. Beyond that, I think you'd have to have a concrete example to compare assembly before and after. The optimizer can do surprising things -- in the above playground, after optimization it's flattened entirely into |
Uh oh!
There was an error while loading. Please reload this page.
cuviper
commented
Apr 14, 2020
@Centril, since it was your request to internalize this, how do you feel about the slightly worse perf results? |
Centril
commented
Apr 14, 2020
@cuviper Hmm; do you know where the regressions are coming from (I haven't checked the diff)? They don't look egregious, so imo correctness comes first in this case, but I wonder if we could have our cake and eat it too? |
cuviper
commented
Apr 14, 2020
Nothing stands out to me -- but just intuitively, there's an extra layer of function calls that have to be inlined away. Even in debug mode, it's simply a little bit more code to compile.
Well, we had chatted about a new language feature like |
Centril
commented
Apr 14, 2020
Ah OK. :) My personal view is that, for now, we should accept the slight regression here, merge the PR, and try to recover it when we can do so in a correct way. |
rakshith-ravi
commented
Apr 15, 2020
@bors try @rust-timer queue |
bors
commented
Apr 15, 2020
@rakshith-ravi: 🔑 Insufficient privileges: not in try users |
rust-timer
commented
Apr 15, 2020
Insufficient permissions to issue commands to rust-timer. |
rakshith-ravi
commented
Apr 15, 2020
Gah! |
Uh oh!
There was an error while loading. Please reload this page.
cuviper
commented
Apr 15, 2020
I don't expect performance will be much different than before, but we can try it. @bors try @rust-timer queue |
rust-timer
commented
Apr 15, 2020
Awaiting bors try build completion |
bors
commented
Apr 15, 2020
⌛ Trying commit abe5973 with merge 26002ac6b8bee06e3c810c453f5771d8b523b1da... |
bors
commented
Apr 15, 2020
☀️ Try build successful - checks-azure |
rust-timer
commented
Apr 15, 2020
Queued 26002ac6b8bee06e3c810c453f5771d8b523b1da with parent 835428c, future comparison URL. |
Mark-Simulacrum
commented
Apr 16, 2020
FYI: We just deployed a PR to the perf collector that in theory reduces noise, but may also introduce other unexpected effects. If the results are odd or otherwise unexpected, it may be worth re-running the try build and the perf run. (Indeed, I would likely recommend just doing so regardless, but up to you). |
rust-timer
commented
Apr 16, 2020
Finished benchmarking try commit 26002ac6b8bee06e3c810c453f5771d8b523b1da, comparison URL. |
rakshith-ravi
commented
Apr 16, 2020
Wait, the CPU cycles has reduced by 10%?!? And the number of instructions have reduced by 20%?!? Is this because of the new PR @Mark-Simulacrum? I mean, I had a hunch that the perf would increase with my new changes, but not this much xD |
Mark-Simulacrum
commented
Apr 16, 2020
We've seen improvements elsewhere, so it's most likely spurious, but let's try it again: @bors try @rust-timer queue |
rust-timer
commented
Apr 16, 2020
Awaiting bors try build completion |
bors
commented
Apr 16, 2020
⌛ Trying commit abe5973 with merge 6524bc32a6a2b550d6fbbb229227b9f5a3cfd876... |
bors
commented
Apr 16, 2020
☀️ Try build successful - checks-azure |
rust-timer
commented
Apr 16, 2020
Queued 6524bc32a6a2b550d6fbbb229227b9f5a3cfd876 with parent 534a41a, future comparison URL. |
cuviper
commented
Apr 16, 2020
The new performance results look pretty tightly neutral -- which is a good thing! @bors r+ rollup |
bors
commented
Apr 16, 2020
📌 Commit abe5973 has been approved by |
Rollup of 7 pull requests Successful merges: - rust-lang#70578 (Add long error explanation for E0657) - rust-lang#70910 (Hides default fns inside Fuse impl to avoid exposing it to any crate) - rust-lang#71164 (reword Miri validity errors: undefined -> uninitialized) - rust-lang#71182 (Add some regression tests) - rust-lang#71206 (Miri error messages: avoid try terminology) - rust-lang#71220 (Dogfood or_patterns in the standard library) - rust-lang#71225 (Fix typo in Default trait docs: Provides -> Provide) Failed merges: r? @ghost
Fixes#70796
@cuviper I've added some default, private traits to do the job for us. If required, I can expose them to a specific visibility if you want to call these functions for #70332
r? @cuviper