Skip to content
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

Work-around optimiser deficiencies in Range iterator. #24705

Closed
wants to merge 1 commit into from

Conversation

huonw
Copy link
Member

@huonw huonw commented Apr 22, 2015

The conditional mutation of the previous implementation resulted in poor
code, making it unconditional makes Range less well behaved as an
Iterator (but still legal) but also makes it fast.

The intention is that this change will be reverted when rustc/LLVM
handle the best-behaved implementation better.

cc #24660

The conditional mutation of the previous implementation resulted in poor
code, making it unconditional makes `Range` less well behaved as an
Iterator (but still legal) but also makes it fast.

The intention is that this change will be reverted when rustc/LLVM
handle the best-behaved implementation better.

cc rust-lang#24660
@rust-highfive
Copy link
Collaborator

r? @aturon

(rust_highfive has picked a reviewer for you, use r? to override)

@aturon
Copy link
Member

aturon commented Apr 23, 2015

Hm, I'm worried about cases where this causes overflow and you have debug assertions enabled (whereas the current code avoids the overflow).

@huonw
Copy link
Member Author

huonw commented Apr 23, 2015

I believe that will only trigger after None has been yielded at least once, so is OK per the "behaviour after None is unspecified" part of Iterator, however, I agree that's a little worrying.

@aturon
Copy link
Member

aturon commented Apr 24, 2015

Oh yes, of course, my apologies for not reading the commentary more carefully.

@bors: r+

@bors
Copy link
Contributor

bors commented Apr 24, 2015

📌 Commit 97b7c76 has been approved by aturon

@bors
Copy link
Contributor

bors commented Apr 25, 2015

⌛ Testing commit 97b7c76 with merge 4e9399c...

@bors
Copy link
Contributor

bors commented Apr 25, 2015

💔 Test failed - auto-linux-64-nopt-t

@pnkfelix
Copy link
Member

@huonw any idea about that build failure?

rustc: x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections
rustc: x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-t/build/src/libstd/path.rs:680:13: 680:14 error: unreachable pattern [E0001]
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-t/build/src/libstd/path.rs:680             _ => Some(Component::Normal(unsafe { u8_slice_as_os_str(comp) }))
                                                                                                   ^
/home/ubuntu/src/rust-buildbot/slave/auto-linux-64-nopt-t/build/src/libstd/path.rs:680:13: 680:14 help: pass `--explain E0001` to see a detailed explanation
error: aborting due to previous error
make: *** [x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib/stamp.std] Error 101
program finished with exit code 2

@pythonesque
Copy link
Contributor

I was just about to report this (and suggest the same solution). Is this still being merged?

@huonw
Copy link
Member Author

huonw commented May 21, 2015

I intend to get it merged, once I can debug the (reproducable) crash... absolutely no idea what is going on with it yet. 😢

@alexcrichton alexcrichton added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jun 2, 2015
@oli-obk
Copy link
Contributor

oli-obk commented Jun 11, 2015

I think I found it: range_inclusive (https://github.com/rust-lang/rust/blob/master/src/libcore/iter.rs#L2799-2808) won't work anymore due to the self.range.start == self.range.end check. This will cause https://github.com/rust-lang/rust/blob/master/src/librustc/middle/check_match.rs#L605 to produce 0 elements for range_inclusive(0, 0)

@alexcrichton
Copy link
Member

Unfortunately I think this is backwards incompatible as-is, so I'm going to close this in the same manner as #26390

@huonw huonw deleted the meh-iterator branch June 18, 2015 22:17
@pythonesque
Copy link
Contributor

This is really, really, really unfortunate. The inability of the existing implementation to optimize properly is kind of absurd. We should at least have something in the documentation indicating this until the codegen is fixed.

@dotdash
Copy link
Contributor

dotdash commented Jun 19, 2015

The original test case that led to this PR optimizes well now. Are there
other cases that still require this change to optimize well?
Am 19.06.2015 19:14 schrieb "Joshua Yanovski" [email protected]:

This is really, really, really unfortunate. The inability of the existing
implementation to optimize properly is kind of absurd. We should at least
have something in the documentation indicating this until the codegen is
fixed.


Reply to this email directly or view it on GitHub
#24705 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants