Skip to content

Speed up obligation forest code #51411

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 4 commits into from
Jun 16, 2018
Merged

Conversation

nnethercote
Copy link
Contributor

Here are the rustc-perf benchmarks that get at least a 1% speedup on one or more of their runs with these patches applied:

inflate-check
        avg: -8.7%      min: -12.1%     max: 0.0%
inflate
        avg: -5.9%      min: -8.6%      max: 1.1%
inflate-opt
        avg: -1.5%      min: -2.0%      max: -0.3%
clap-rs-check
        avg: -0.6%      min: -1.9%      max: 0.5%
coercions
        avg: -0.2%?     min: -1.3%?     max: 0.6%?
serde-opt
        avg: -0.6%      min: -1.0%      max: 0.1%
coercions-check
        avg: -0.4%?     min: -1.0%?     max: -0.0%?

@rust-highfive
Copy link
Contributor

r? @michaelwoerister

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 7, 2018
`process_predicates` returns a
`Result<Option<Vec<PredicateObligation>>>`. `process_obligation` calls
it and then fiddles with the output (using `map`, `map`, `into_iter`,
`collect`) to produce a a
`Result<Option<Vec<PendingPredicateObligation>>>`.

This function is sufficiently hot that the fiddling is expensive. It's
much better for `process_predicate` to directly return a
`Result<Option<Vec<PendingPredicateObligation>>>` because `Ok(None)`
accounts for ~90% of the results, and `Ok(vec![])` accounts for another
~5%.
Because it has a single callsite.

This patch is large but trivial, doing the minimal amount of work
(mostly `self.` insertions) necessary.
It's very hot, and this speeds things up.
A tri-valued enum is nicer than Result<Option<T>>, and it's slightly
faster.
@michaelwoerister
Copy link
Member

r? @nikomatsakis

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 15, 2018

📌 Commit c83d152 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 Jun 15, 2018
@bors
Copy link
Collaborator

bors commented Jun 15, 2018

⌛ Testing commit c83d152 with merge b541bf54dca84e576bb481a6992bf743dcebf8bd...

@bors
Copy link
Collaborator

bors commented Jun 15, 2018

💔 Test failed - status-travis

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

The job dist-i686-apple of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:02:54]       Memory: 8 GB
[00:02:54]       Boot ROM Version: VMW71.00V.0.B64.1704110547
[00:02:54]       Apple ROM Info: [MS_VM_CERT/SHA1/27d66596a61c48dd3dc7216fd715126e33f59ae7]Welcome to the Virtual Machine
[00:02:54]       SMC Version (system): 2.8f0
[00:02:54]       Serial Number (system): VMlNH6iM8hLT
[00:02:54] 
[00:02:54] hw.ncpu: 4
[00:02:54] hw.byteorder: 1234
[00:02:54] hw.memsize: 8589934592
---
travis_fold:end:dpl_0
travis_time:start:141a70dc
travis_fold:start:dpl.1
Installing deploy dependencies
ERROR:  Could not find a valid gem 'aws-sdk-resources' (= 2.11.70) in any repository
ERROR:  Possible alternatives: aws-sdk-resources
/Users/travis/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- dpl/provider/s3 (LoadError)
 from /Users/travis/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/provider.rb:93:in `rescue in block in new'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/provider.rb:68:in `block in new'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/cli.rb:41:in `fold'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/provider.rb:67:in `new'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/cli.rb:31:in `run'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/cli.rb:7:in `run'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/bin/dpl:5:in `<top (required)>'
 from /Users/travis/.rvm/gems/ruby-2.4.2/bin/dpl:23:in `load'
 from /Users/travis/.rvm/gems/ruby-2.4.2/bin/dpl:23:in `<main>'
failed to deploy
failed to deploy
No output has been received in the last 30m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

1 similar comment
@rust-highfive
Copy link
Contributor

The job dist-i686-apple of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:02:54]       Memory: 8 GB
[00:02:54]       Boot ROM Version: VMW71.00V.0.B64.1704110547
[00:02:54]       Apple ROM Info: [MS_VM_CERT/SHA1/27d66596a61c48dd3dc7216fd715126e33f59ae7]Welcome to the Virtual Machine
[00:02:54]       SMC Version (system): 2.8f0
[00:02:54]       Serial Number (system): VMlNH6iM8hLT
[00:02:54] 
[00:02:54] hw.ncpu: 4
[00:02:54] hw.byteorder: 1234
[00:02:54] hw.memsize: 8589934592
---
travis_fold:end:dpl_0
travis_time:start:141a70dc
travis_fold:start:dpl.1
Installing deploy dependencies
ERROR:  Could not find a valid gem 'aws-sdk-resources' (= 2.11.70) in any repository
ERROR:  Possible alternatives: aws-sdk-resources
/Users/travis/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- dpl/provider/s3 (LoadError)
 from /Users/travis/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/provider.rb:93:in `rescue in block in new'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/provider.rb:68:in `block in new'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/cli.rb:41:in `fold'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/provider.rb:67:in `new'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/cli.rb:31:in `run'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/lib/dpl/cli.rb:7:in `run'
 from /Users/travis/.rvm/gems/ruby-2.4.2/gems/dpl-1.9.7/bin/dpl:5:in `<top (required)>'
 from /Users/travis/.rvm/gems/ruby-2.4.2/bin/dpl:23:in `load'
 from /Users/travis/.rvm/gems/ruby-2.4.2/bin/dpl:23:in `<main>'
failed to deploy
failed to deploy
No output has been received in the last 30m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nnethercote
Copy link
Contributor Author

ERROR: Could not find a valid gem 'aws-sdk-resources' (= 2.11.70) in any repository

This is clearly an infra failure.

@Mark-Simulacrum
Copy link
Member

@bors retry

@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 16, 2018
@bors
Copy link
Collaborator

bors commented Jun 16, 2018

⌛ Testing commit c83d152 with merge 68cee8b...

bors added a commit that referenced this pull request Jun 16, 2018
Speed up obligation forest code

Here are the rustc-perf benchmarks that get at least a 1% speedup on one or more of their runs with these patches applied:
```
inflate-check
        avg: -8.7%      min: -12.1%     max: 0.0%
inflate
        avg: -5.9%      min: -8.6%      max: 1.1%
inflate-opt
        avg: -1.5%      min: -2.0%      max: -0.3%
clap-rs-check
        avg: -0.6%      min: -1.9%      max: 0.5%
coercions
        avg: -0.2%?     min: -1.3%?     max: 0.6%?
serde-opt
        avg: -0.6%      min: -1.0%      max: 0.1%
coercions-check
        avg: -0.4%?     min: -1.0%?     max: -0.0%?
```
@bors
Copy link
Collaborator

bors commented Jun 16, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 68cee8b to master...

@bors bors merged commit c83d152 into rust-lang:master Jun 16, 2018
@nnethercote nnethercote deleted the process_predicate branch June 17, 2018 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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