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

Rewrite precompute_borrows_out_of_scope for fewer hash table lookups. #53942

Merged
merged 1 commit into from
Sep 8, 2018

Conversation

nnethercote
Copy link
Contributor

It now does one hash table lookup per basic block, instead of one per
statement. This is worthwhile because this function is hot for NLL
builds of ucd.

I haven't measured the effect of this yet because I'm having trouble doing optimized builds of rustc that are suitable for profiling (#53916). I will do an online perf run instead.

r? @nikomatsakis

It now does one hash table lookup per basic block, instead of one per
statement. This is worthwhile because this function is hot for NLL
builds of `ucd`.
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 4, 2018
@nnethercote
Copy link
Contributor Author

@bors try

@bors
Copy link
Contributor

bors commented Sep 4, 2018

⌛ Trying commit fb307e5 with merge e6588839b5a4ae34dab4c5c8e5a9b7e49699c3ee...

@bors
Copy link
Contributor

bors commented Sep 4, 2018

☀️ Test successful - status-travis
State: approved= try=True

@nnethercote
Copy link
Contributor Author

@rust-timer build e6588839b5a4ae34dab4c5c8e5a9b7e49699c3ee

@rust-timer
Copy link
Collaborator

Success: Queued e6588839b5a4ae34dab4c5c8e5a9b7e49699c3ee with parent 8b80390, comparison URL.

@nnethercote
Copy link
Contributor Author

BTW, I verified the correctness of this by implementing the new code alongside the old code, running both in tandem, and asserting that the HashSets of visited nodes matched each other.

@memoryruins memoryruins added the A-NLL Area: Non-lexical lifetimes (NLL) label Sep 4, 2018
@ljedrz
Copy link
Contributor

ljedrz commented Sep 4, 2018

Perf results are in; ucd-check improves by almost 60%.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

This is nice.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 4, 2018

📌 Commit fb307e5 has been approved by nikomatsakis

@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 Sep 4, 2018
@nnethercote
Copy link
Contributor Author

nnethercote commented Sep 4, 2018

Perf results are in; ucd-check improves by almost 60%.

Yay! And it's a 1% NLL win for html5ever-check, too.

@nikomatsakis: I have one question. Each BB has N statements, with indices 0..N, plus a terminator at index N. Currently, the terminator location gets tested by region_contains(), and I don't know if that is valid or not.

@nikomatsakis
Copy link
Contributor

@nnethercote

Currently, the terminator location gets tested by region_contains(), and I don't know if that is valid or not.

This is correct, the terminator location is no different from the others from the POV of this code.

@nnethercote
Copy link
Contributor Author

I bet $5 that #53909 will end up landing before this does, in which case this PR will provide (a) a 1% html5ever-check NLL win, and (b) future protection against other potential bad cases.

@pnkfelix
Copy link
Member

pnkfelix commented Sep 6, 2018

I bet $5 that #53909 will end up landing before this does, ...

well that is an interesting technique to try to get your PR some favoritism from the reviewers! 😉

@nnethercote
Copy link
Contributor Author

48 hours ago this PR was 10th in Homu's queue. It's now 11th. I find Homu frustrating: #37107

kennytm added a commit to kennytm/rust that referenced this pull request Sep 8, 2018
…komatsakis

Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.

It now does one hash table lookup per basic block, instead of one per
statement. This is worthwhile because this function is hot for NLL
builds of `ucd`.

I haven't measured the effect of this yet because I'm having trouble doing optimized builds of rustc that are suitable for profiling (rust-lang#53916). I will do an online perf run instead.

r? @nikomatsakis
bors added a commit that referenced this pull request Sep 8, 2018
Rollup of 11 pull requests

Successful merges:

 - #51366 (stabilize #[panic_handler])
 - #53162 (rustdoc: collect trait impls as an early pass)
 - #53932 ([NLL] Remove base_place)
 - #53942 (Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.)
 - #53973 (Have rust-lldb look for the rust-enabled lldb)
 - #53981 (Implement initializer() for FileDesc)
 - #53987 (rustbuild: allow configuring llvm version suffix)
 - #53993 (rustc_resolve: don't record uniform_paths canaries as reexports.)
 - #54007 (crates that provide a `panic_handler` are exempt from the `unused_extern_crates` lint)
 - #54040 (update books for next release)
 - #54050 (Update `petgraph` dependency to 0.4.13 to fix build with nightly)

Failed merges:

r? @ghost
kennytm added a commit to kennytm/rust that referenced this pull request Sep 8, 2018
…komatsakis

Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.

It now does one hash table lookup per basic block, instead of one per
statement. This is worthwhile because this function is hot for NLL
builds of `ucd`.

I haven't measured the effect of this yet because I'm having trouble doing optimized builds of rustc that are suitable for profiling (rust-lang#53916). I will do an online perf run instead.

r? @nikomatsakis
bors added a commit that referenced this pull request Sep 8, 2018
Rollup of 10 pull requests

Successful merges:

 - #53315 (use `NonZeroU32` in `newtype_index!`macro, change syntax)
 - #53932 ([NLL] Remove base_place)
 - #53942 (Rewrite `precompute_borrows_out_of_scope` for fewer hash table lookups.)
 - #53973 (Have rust-lldb look for the rust-enabled lldb)
 - #53981 (Implement initializer() for FileDesc)
 - #53987 (rustbuild: allow configuring llvm version suffix)
 - #53993 (rustc_resolve: don't record uniform_paths canaries as reexports.)
 - #54007 (crates that provide a `panic_handler` are exempt from the `unused_extern_crates` lint)
 - #54040 (update books for next release)
 - #54050 (Update `petgraph` dependency to 0.4.13 to fix build with nightly)
@bors bors merged commit fb307e5 into rust-lang:master Sep 8, 2018
@nnethercote nnethercote deleted the faster-precompute branch September 9, 2018 22:18
@nnethercote
Copy link
Contributor Author

I bet $5 that #53909 will end up landing before this does

It did, by about 4 hours.

@lqd
Copy link
Member

lqd commented Sep 10, 2018

@nnethercote it looks more like yours merged 8h before #53909 (in my timezone of GMT+2: 4PM Sept 8, while 53909 did on Sept 9 at 20 minutes after midnight :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) 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.

9 participants