Skip to content

Use slice parts in PartialEq for VecDeque #31420

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

Merged
merged 1 commit into from
Feb 10, 2016
Merged

Conversation

bluss
Copy link
Member

@bluss bluss commented Feb 5, 2016

collections: Use slice parts in PartialEq for VecDeque

This improves == for VecDeque by using the slice representation.

This will also improve further if codegen for slice comparison improves.

Benchmark run of 1000 u64 elements, comparing for equality (all equal).
Cpu time to compare the vecdeques is reduced to less than 50% of what it
was before.

test test_eq_u64       ... bench:  1,885 ns/iter (+/- 163) = 4244 MB/s
test test_eq_new_u64   ... bench:    802 ns/iter (+/- 100) = 9975 MB/s

This improves == for VecDeque by using the slice representation.

This will also improve further if codegen for slice comparison improves.

Benchmark run of 1000 u64 elements, comparing for equality (all equal).
Cpu time to compare the vecdeques is reduced to less than 50% of what it
was before.

```
test test_eq_u64       ... bench:  1,885 ns/iter (+/- 163) = 4244 MB/s
test test_eq_new_u64   ... bench:    802 ns/iter (+/- 100) = 9975 MB/s
```
@bluss
Copy link
Member Author

bluss commented Feb 5, 2016

This is for consideration.

Not sure here, it feels like bloat. Ideally we'd trust the compiler with the inlining decisions here but, I'm not sure. It wins microbenchmarks for comparing equal vecdeques for sure.

@bluss bluss changed the title Use slices parts in PartialEq for VecDeque Use slice parts in PartialEq for VecDeque Feb 5, 2016
@alexcrichton
Copy link
Member

r? @gankro

@Gankra
Copy link
Contributor

Gankra commented Feb 10, 2016

@bors r+

The win is clear, the bloat is unlikely to be a problem.

@bors
Copy link
Collaborator

bors commented Feb 10, 2016

📌 Commit aeb3aba has been approved by Gankro

@bors
Copy link
Collaborator

bors commented Feb 10, 2016

⌛ Testing commit aeb3aba with merge 0efe43d...

@bors
Copy link
Collaborator

bors commented Feb 10, 2016

💔 Test failed - auto-linux-32-opt

@alexcrichton
Copy link
Member

@bors: retry

On Wed, Feb 10, 2016 at 12:03 AM, bors [email protected] wrote:

[image: 💔] Test failed - auto-linux-32-opt
http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/8036


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

@bors
Copy link
Collaborator

bors commented Feb 10, 2016

⌛ Testing commit aeb3aba with merge 32d962d...

bors added a commit that referenced this pull request Feb 10, 2016
collections: Use slice parts in PartialEq for VecDeque

This improves == for VecDeque by using the slice representation.

This will also improve further if codegen for slice comparison improves.

Benchmark run of 1000 u64 elements, comparing for equality (all equal).
Cpu time to compare the vecdeques is reduced to less than 50% of what it
was before.

```
test test_eq_u64       ... bench:  1,885 ns/iter (+/- 163) = 4244 MB/s
test test_eq_new_u64   ... bench:    802 ns/iter (+/- 100) = 9975 MB/s
```
@bors bors merged commit aeb3aba into rust-lang:master Feb 10, 2016
@bluss bluss deleted the deque-equality branch February 10, 2016 14:28
@bluss
Copy link
Member Author

bluss commented Feb 10, 2016

@gankro We can always revisit later! llvm will use its judgement for inlining and so on. A target for the future is to improve the slice's own equality comparison.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants