-
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
rustc apparently optimizes away the loop in 3.3 #28713
Comments
sorry - I thought I was following the link to submit an issue with the Rust Book, but it appears I've submitted an issue to the Rust language proper :( |
@lojic the book issues are part of the repo here, yes. |
Also, I believe that we either 1) did something to fix this, or 2) there's already an issue open, would you mind checking the nightly book and the other issues? |
The example in the book still exhibits the "optimized away" problem. I scanned through all the "A-docs" issues and didn't see anything that matched, but I may have missed something. |
Sorry, missed "nightly" above - I'll check that... |
Nightly appears to be the same as stable - just a simple loop that rustc is smart enough to collapse. |
Roger. Thanks for checking, maybe I'm imagining things. |
Some history: While getting Rust to 1.0, it was a struggle to keep the book in a working state. I had always wanted a certain kind of TOC, but couldn't quite get it there. At the 11th hour, I wrote up "Rust inside other langauges" and "Dining Philosophers" in an attempt to get the book in the direction I wanted to go. They were fine, but not my best work. I wanted to further expand this section, but it's just never going to end up happening. We're doing the second draft of the book now, and these sections are basically gone already. Here's the issues with these two sections, and removing them just fixes it all: // Philosophers There was always controversy over which ones were chosen, and why. This is kind of a perpetual bikeshed, but it comes up every once in a while. The implementation was originally supposed to show off channels, but never did, due to time constraints. Months later, I still haven't re-written it to use them. People get different results and assume that means they're wrong, rather than the non-determinism inherent in concurrency. Platform differences aggrivate this, as does the exact amount of sleeping and printing. // Rust Inside Other Languages This section is wonderful, and shows off a strength of Rust. However, it's not clear what qualifies a language to be in this section. And I'm not sure how tracking a ton of other languages is gonna work, into the future; we can't test _anything_ in this section, so it's prone to bitrot. By removing this section, and making the Guessing Game an initial tutorial, we will move this version of the book closer to the future version, and just eliminate all of these questions. In addition, this also solves the 'split-brained'-ness of having two paths, which has endlessly confused people in the past. I'm sad to see these sections go, but I think it's for the best. Fixes rust-lang#30471 Fixes rust-lang#30163 Fixes rust-lang#30162 Fixes rust-lang#25488 Fixes rust-lang#30345 Fixes rust-lang#29590 Fixes rust-lang#28713 Fixes rust-lang#28915 And probably others. This lengthy list alone is enough to show that these should have been removed. RIP.
…ankro Some history: While getting Rust to 1.0, it was a struggle to keep the book in a working state. I had always wanted a certain kind of TOC, but couldn't quite get it there. At the 11th hour, I wrote up "Rust inside other langauges" and "Dining Philosophers" in an attempt to get the book in the direction I wanted to go. They were fine, but not my best work. I wanted to further expand this section, but it's just never going to end up happening. We're doing the second draft of the book now, and these sections are basically gone already. Here's the issues with these two sections, and removing them just fixes it all: // Philosophers There was always controversy over which ones were chosen, and why. This is kind of a perpetual bikeshed, but it comes up every once in a while. The implementation was originally supposed to show off channels, but never did, due to time constraints. Months later, I still haven't re-written it to use them. People get different results and assume that means they're wrong, rather than the non-determinism inherent in concurrency. Platform differences aggrivate this, as does the exact amount of sleeping and printing. // Rust Inside Other Languages This section is wonderful, and shows off a strength of Rust. However, it's not clear what qualifies a language to be in this section. And I'm not sure how tracking a ton of other languages is gonna work, into the future; we can't test _anything_ in this section, so it's prone to bitrot. By removing this section, and making the Guessing Game an initial tutorial, we will move this version of the book closer to the future version, and just eliminate all of these questions. In addition, this also solves the 'split-brained'-ness of having two paths, which has endlessly confused people in the past. I'm sad to see these sections go, but I think it's for the best. Fixes rust-lang#30471 Fixes rust-lang#30163 Fixes rust-lang#30162 Fixes rust-lang#25488 Fixes rust-lang#30345 Fixes rust-lang#29590 Fixes rust-lang#28713 Fixes rust-lang#28915 And probably others. This lengthy list alone is enough to show that these should have been removed. RIP.
Some history: While getting Rust to 1.0, it was a struggle to keep the book in a working state. I had always wanted a certain kind of TOC, but couldn't quite get it there. At the 11th hour, I wrote up "Rust inside other langauges" and "Dining Philosophers" in an attempt to get the book in the direction I wanted to go. They were fine, but not my best work. I wanted to further expand this section, but it's just never going to end up happening. We're doing the second draft of the book now, and these sections are basically gone already. Here's the issues with these two sections, and removing them just fixes it all: // Philosophers There was always controversy over which ones were chosen, and why. This is kind of a perpetual bikeshed, but it comes up every once in a while. The implementation was originally supposed to show off channels, but never did, due to time constraints. Months later, I still haven't re-written it to use them. People get different results and assume that means they're wrong, rather than the non-determinism inherent in concurrency. Platform differences aggrivate this, as does the exact amount of sleeping and printing. // Rust Inside Other Languages This section is wonderful, and shows off a strength of Rust. However, it's not clear what qualifies a language to be in this section. And I'm not sure how tracking a ton of other languages is gonna work, into the future; we can't test _anything_ in this section, so it's prone to bitrot. By removing this section, and making the Guessing Game an initial tutorial, we will move this version of the book closer to the future version, and just eliminate all of these questions. In addition, this also solves the 'split-brained'-ness of having two paths, which has endlessly confused people in the past. I'm sad to see these sections go, but I think it's for the best. Fixes rust-lang#30471 Fixes rust-lang#30163 Fixes rust-lang#30162 Fixes rust-lang#25488 Fixes rust-lang#30345 Fixes rust-lang#28713 Fixes rust-lang#28915 And probably others. This lengthy list alone is enough to show that these should have been removed. RIP.
Some history: While getting Rust to 1.0, it was a struggle to keep the book in a working state. I had always wanted a certain kind of TOC, but couldn't quite get it there. At the 11th hour, I wrote up "Rust inside other langauges" and "Dining Philosophers" in an attempt to get the book in the direction I wanted to go. They were fine, but not my best work. I wanted to further expand this section, but it's just never going to end up happening. We're doing the second draft of the book now, and these sections are basically gone already. Here's the issues with these two sections, and removing them just fixes it all: // Philosophers There was always controversy over which ones were chosen, and why. This is kind of a perpetual bikeshed, but it comes up every once in a while. The implementation was originally supposed to show off channels, but never did, due to time constraints. Months later, I still haven't re-written it to use them. People get different results and assume that means they're wrong, rather than the non-determinism inherent in concurrency. Platform differences aggrivate this, as does the exact amount of sleeping and printing. // Rust Inside Other Languages This section is wonderful, and shows off a strength of Rust. However, it's not clear what qualifies a language to be in this section. And I'm not sure how tracking a ton of other languages is gonna work, into the future; we can't test _anything_ in this section, so it's prone to bitrot. By removing this section, and making the Guessing Game an initial tutorial, we will move this version of the book closer to the future version, and just eliminate all of these questions. In addition, this also solves the 'split-brained'-ness of having two paths, which has endlessly confused people in the past. I'm sad to see these sections go, but I think it's for the best. Fixes #30471 Fixes #30163 Fixes #30162 Fixes #25488 Fixes #30345 Fixes #29590 Fixes #28713 Fixes #28915 And probably others. This lengthy list alone is enough to show that these should have been removed. RIP.
I just implemented the code in section 3.3 to compare Ruby to Rust. It appears that rustc optimizes away the inner loop of the thread, because I kept increasing the limit and the completion time remained constant. I introduced a simple if statement in the loop, and then I got expected timings.
It might be worth modifying the loop so it's not optimized away for a fairer comparison. Here's what I ended up with:
The text was updated successfully, but these errors were encountered: