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

BTree: encapsulate LeafRange better & some debug asserts #85980

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

ssomers
Copy link
Contributor

@ssomers ssomers commented Jun 3, 2021

Looking at iterators again, I think #81937 didn't house enough code in LeafRange. Moving the API boundary a little makes things more local in navigate.rs and less complicated in map.rs.

r? @Mark-Simulacrum

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 3, 2021
@ssomers
Copy link
Contributor Author

ssomers commented Jun 5, 2021

added a comment + added debug assert on such unwrap_uncheckeds

@ssomers
Copy link
Contributor Author

ssomers commented Jun 5, 2021

split up benchmarks to better illustrate the disappointment that started #62924

@ssomers ssomers force-pushed the btree_cleanup_LeafRange branch 2 times, most recently from 3f0ba42 to bb0c017 Compare June 6, 2021 01:40
@Mark-Simulacrum
Copy link
Member

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 7, 2021
@bors
Copy link
Contributor

bors commented Jun 7, 2021

⌛ Trying commit bb0c01770e325d66292ee8ea84ef1eaf1ba249af with merge 078cf1207b1bbbf628b7e0b76de039fea4fb6d59...

@bors
Copy link
Contributor

bors commented Jun 7, 2021

☀️ Try build successful - checks-actions
Build commit: 078cf1207b1bbbf628b7e0b76de039fea4fb6d59 (078cf1207b1bbbf628b7e0b76de039fea4fb6d59)

@rust-timer
Copy link
Collaborator

Queued 078cf1207b1bbbf628b7e0b76de039fea4fb6d59 with parent 35fff69, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (078cf1207b1bbbf628b7e0b76de039fea4fb6d59): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 7, 2021
@ssomers
Copy link
Contributor Author

ssomers commented Jun 7, 2021

Lots of red, which to me means, if anything, that #74615 is still haunting unwrap_unchecked. So I could revert back to unwrap for these, or others, but earlier in #74693 you seemed to prefer not to.

@ssomers
Copy link
Contributor Author

ssomers commented Jun 8, 2021

As to library/alloc benchmarks:

  • Reverting to unwrap in deallocating_next_unchecked influences the times of various benchmarks a bit, including the only benchmarks that actually invoke that function (clone_X_and_into_iter), but they don't stand out at all. Which seems normal because the change is tiny compared to all the allocation and deallocation happening.
  • Reverting to unwrap in deallocating_next_back_unchecked doesn't change timing at all (barring the 2% noise of cosmic radiation), which is comforting because reverse iteration is not benchmarked.
  • Reverting both, thus just reorganizing functions, still influences timing compared to master. Also (but differently) when introducing inlines.

@Mark-Simulacrum
Copy link
Member

I am happy with modifications to use of unwrap_unchecked; generally, if we can not use it and the performance does not show problems, we shouldn't use it. (Obviously, if performance improves, then not using it seems better). I think this may be a change in opinion from the other PR; I'd be ok accepting a rebased version of it presuming perf.rlo was neutral or an improvement.

@ssomers
Copy link
Contributor Author

ssomers commented Jun 9, 2021

I'd be ok accepting a rebased version of it presuming perf.rlo was neutral or an improvement.

#74693 was about the btree's private unwrap_unchecked, now we use the one Option shares. I tried the equivalent of changing the unwrap_unchecked to unwrap in all btree code, many months ago, and it didn't help performance like it did at the time of #74693. That's just a simple micro-optimisation of the iterator code. Very recently, I tried unifying the separate _checked and _unchecked implementations, that this PR merely makes stand out more. It leaves the code a lot more pleasant to read & write, but performance suffers significantly. But all that performance talk is according to the alloc benchmarks, and I have no idea how it would stand up in court.

Anyway, for the time being, here's a rebased version with the two unwrap reverted, and the new functions that used to be literally inlined #[inline]'d (including two that already existed as private Range methods but are now public in a private module, whatever difference that makes). If this still isn't performance neutral, I'm at a loss.

@Mark-Simulacrum
Copy link
Member

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 9, 2021
@bors
Copy link
Contributor

bors commented Jun 9, 2021

⌛ Trying commit b9d43c6 with merge 013ba6f7c5a4503fd819fadde66647e054355c7c...

@Mark-Simulacrum Mark-Simulacrum removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 9, 2021
@bors
Copy link
Contributor

bors commented Jun 9, 2021

☀️ Try build successful - checks-actions
Build commit: 013ba6f7c5a4503fd819fadde66647e054355c7c (013ba6f7c5a4503fd819fadde66647e054355c7c)

@rust-timer
Copy link
Collaborator

Queued 013ba6f7c5a4503fd819fadde66647e054355c7c with parent eab201d, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (013ba6f7c5a4503fd819fadde66647e054355c7c): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 10, 2021
@ssomers ssomers changed the title BTree: encapsulate LeafRange better, use unwrap_unchecked more BTree: encapsulate LeafRange better & some debug asserts Jun 10, 2021
@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 20, 2021

📌 Commit b9d43c6 has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 20, 2021
@bors
Copy link
Contributor

bors commented Jun 20, 2021

⌛ Testing commit b9d43c6 with merge 03b845a...

@bors
Copy link
Contributor

bors commented Jun 21, 2021

☀️ Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 03b845a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 21, 2021
@bors bors merged commit 03b845a into rust-lang:master Jun 21, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jun 21, 2021
@ssomers ssomers deleted the btree_cleanup_LeafRange branch June 21, 2021 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants