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

Optimize ChunkedBitSet dense relations #94625

Closed

Conversation

martingms
Copy link
Contributor

ChunkedBitSet::subtract(&HybridBitSet) showed up in a callgrind profile grabbed of the helloworld benchmark while playing around with rustc-perf, and the FIXMEs left behind there by @nnethercote pointed to a way to optimize it.

The resulting improvements on the rustc-perf benchmarks are meager to say the least, but perhaps the changes are of interest anyway.

I'm unacquainted with the compiler code and the tooling in general so I apologize in advance for any missteps!

PS: Sorry for the double PR, the first one was supposed to be a draft!

r? @nnethercote

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 4, 2022
@rust-highfive
Copy link
Collaborator

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

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 Mar 4, 2022
@nnethercote
Copy link
Contributor

Let's do a perf run on CI before I review this.

@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 Mar 4, 2022
@bors
Copy link
Contributor

bors commented Mar 4, 2022

⌛ Trying commit 2ffe6f3 with merge 7d921874adb595b7bb13072cc2c7b70a015e679d...

@bors
Copy link
Contributor

bors commented Mar 4, 2022

☀️ Try build successful - checks-actions
Build commit: 7d921874adb595b7bb13072cc2c7b70a015e679d (7d921874adb595b7bb13072cc2c7b70a015e679d)

@rust-timer
Copy link
Collaborator

Queued 7d921874adb595b7bb13072cc2c7b70a015e679d with parent 9fcbc32, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7d921874adb595b7bb13072cc2c7b70a015e679d): comparison url.

Summary: This benchmark run did not return any relevant results.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf.

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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 5, 2022
assert_eq!(self.domain_size, other.domain_size());

let mut changed = false;
for (chunk, other_words) in self.chunks.iter_mut().zip(other.words().chunks(CHUNK_WORDS)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this chunks() method defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nnethercote
Copy link
Contributor

Thank you for the pull request! Well done on navigating the contribution process and completing it, everything looks fine in terms of how you've gone about it. I particularly like that you split it up into three logical commits. Hopefully we can look forward to more contributions from you in the future 😄

I admit I am torn on this one. On one hand, the code looks good, much how I would expect. On the other hand, it's a bunch of extra lines of code and corresponding complexity that doesn't provide any measurable performance benefit. I have written plenty of PRs that I thought would help performance and then didn't, and ended up closing them, and my sense of engineering trade-offs is pushing me to do the same thing here. Sorry about that. One thing you could do is file another PR that adds comments to union and subtract, pointing at this PR, so this code is findable in the future should we identify a situation where faster versions of these operations would make a measurable difference. Does that make sense?

@martingms
Copy link
Contributor Author

Sorry about that.

Don't be! I just needed something to work on at a hack night to improve my rust skills, no reason to merge unless it adds value.

One thing you could do is file another PR that adds comments to union and subtract, pointing at this PR, so this code is findable in the future should we identify a situation where faster versions of these operations would make a measurable difference. Does that make sense?

Sure I can do that :)

@martingms martingms closed this Mar 7, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 7, 2022
…nethercote

Add link to closed PR for future optimizers of ChunkedBitSet relations

While optimizing these operations proved unfruitful w.r.t. improving compiler performance right now, faster versions might be needed at a later time. This PR adds a link in the FIXME to save any future optimizers some time, as requested by `@nnethercote` in rust-lang#94625.

r? `@nnethercote`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants