Skip to content

librustc_data_structures: Speedup union of sparse and dense hybrid set #61020

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 3 commits into from
Jun 22, 2019

Conversation

197g
Copy link
Contributor

@197g 197g commented May 21, 2019

This optimization speeds up the union of a hybrid bitset when that
switches it from a sparse representation to a dense bitset. It now
clones the dense bitset and integrate only the spare elements instead of
densifying the sparse bitset, initializing all elements, and then a
union on two dense bitset, touching all words a second time.

It's not completely certain if the added complexity is worth it but I would
like to hear some feedback in any case. Benchmark results from my machine:

Now:  bit_set::union_hybrid_sparse_to_dense ... bench:          72 ns/iter (+/- 5)
Previous: bit_set::union_hybrid_sparse_to_dense ... bench:          90 ns/iter (+/- 6)

This being the second iteration of trying to improve the speed, since I missed the return value in the first, and forgot to run the relevant tests. Oops.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @matthewjasper (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 21, 2019
@Centril
Copy link
Contributor

Centril commented May 22, 2019

@bors try

@bors
Copy link
Collaborator

bors commented May 22, 2019

⌛ Trying commit 3d67c2d with merge b7a0ff7...

bors added a commit that referenced this pull request May 22, 2019
librustc_data_structures: Speedup union of sparse and dense hybrid set

This optimization speeds up the union of a hybrid bitset when that
switches it from a sparse representation to a dense bitset. It now
clones the dense bitset and integrate only the spare elements instead of
densifying the sparse bitset, initializing all elements, and then a
union on two dense bitset, touching all words a second time.

It's not completely certain if the added complexity is worth it but I would
like to hear some feedback in any case. Benchmark results from my machine:

```
Now:  bit_set::union_hybrid_sparse_to_dense ... bench:          72 ns/iter (+/- 5)
Previous: bit_set::union_hybrid_sparse_to_dense ... bench:          90 ns/iter (+/- 6)
```

This being the second iteration of trying to improve the speed, since I missed the return value in the first, and forgot to run the relevant tests. Oops.
@bors
Copy link
Collaborator

bors commented May 22, 2019

☀️ Try build successful - checks-travis
Build commit: b7a0ff7

@Centril
Copy link
Contributor

Centril commented May 22, 2019

@rust-timer build b7a0ff7

@rust-timer
Copy link
Collaborator

Success: Queued b7a0ff7 with parent 119bbc2, comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit b7a0ff7: comparison url

@197g
Copy link
Contributor Author

197g commented May 22, 2019

Doesn't really seem conclusive either way, maybe the benchmark is not as representative of the usage of the operation as I thought. I'll investigate

197g added 3 commits May 22, 2019 16:16
This optimization speeds up the union of a hybrid bitset when that
switches it from a sparse representation to a dense bitset. It now
clones the dense bitset and integrate only the spare elements instead of
densifying the sparse bitset, initializing all elements, and then a
union on two dense bitset, touching all words a second time.
Explains the thought process behind adding the union algorithm and
discusses the alternative and heuristic behind.
@197g
Copy link
Contributor Author

197g commented May 22, 2019

@Centril Can we try again?

@Centril
Copy link
Contributor

Centril commented May 23, 2019

@bors try

"Do, or do not. There is no try." -- Yoda

@bors
Copy link
Collaborator

bors commented May 23, 2019

⌛ Trying commit 3f28811 with merge 9d4d0f3...

bors added a commit that referenced this pull request May 23, 2019
librustc_data_structures: Speedup union of sparse and dense hybrid set

This optimization speeds up the union of a hybrid bitset when that
switches it from a sparse representation to a dense bitset. It now
clones the dense bitset and integrate only the spare elements instead of
densifying the sparse bitset, initializing all elements, and then a
union on two dense bitset, touching all words a second time.

It's not completely certain if the added complexity is worth it but I would
like to hear some feedback in any case. Benchmark results from my machine:

```
Now:  bit_set::union_hybrid_sparse_to_dense ... bench:          72 ns/iter (+/- 5)
Previous: bit_set::union_hybrid_sparse_to_dense ... bench:          90 ns/iter (+/- 6)
```

This being the second iteration of trying to improve the speed, since I missed the return value in the first, and forgot to run the relevant tests. Oops.
@bors
Copy link
Collaborator

bors commented May 23, 2019

☀️ Try build successful - checks-travis
Build commit: 9d4d0f3

@Centril
Copy link
Contributor

Centril commented May 23, 2019

@rust-timer build 9d4d0f3

@rust-timer
Copy link
Collaborator

Success: Queued 9d4d0f3 with parent 11f01bf, comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 9d4d0f3: comparison url

@jonas-schievink
Copy link
Contributor

Ping from triage @matthewjasper, this is waiting on your review. Feel free to assign someone else if you don't have time though.

@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 22, 2019

📌 Commit 3f28811 has been approved by matthewjasper

@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 22, 2019
@bors
Copy link
Collaborator

bors commented Jun 22, 2019

⌛ Testing commit 3f28811 with merge 4a365a2...

bors added a commit that referenced this pull request Jun 22, 2019
librustc_data_structures: Speedup union of sparse and dense hybrid set

This optimization speeds up the union of a hybrid bitset when that
switches it from a sparse representation to a dense bitset. It now
clones the dense bitset and integrate only the spare elements instead of
densifying the sparse bitset, initializing all elements, and then a
union on two dense bitset, touching all words a second time.

It's not completely certain if the added complexity is worth it but I would
like to hear some feedback in any case. Benchmark results from my machine:

```
Now:  bit_set::union_hybrid_sparse_to_dense ... bench:          72 ns/iter (+/- 5)
Previous: bit_set::union_hybrid_sparse_to_dense ... bench:          90 ns/iter (+/- 6)
```

This being the second iteration of trying to improve the speed, since I missed the return value in the first, and forgot to run the relevant tests. Oops.
@bors
Copy link
Collaborator

bors commented Jun 22, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: matthewjasper
Pushing 4a365a2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 22, 2019
@bors bors merged commit 3f28811 into rust-lang:master Jun 22, 2019
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.

7 participants