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

Use optimized SmallVec implementation #53384

Merged
merged 1 commit into from
Aug 23, 2018

Conversation

gootorov
Copy link
Contributor

This PR replaces current SmallVec implementation with the one from the Servo project.

Closes #51640

r? @Mark-Simulacrum

@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 @Mark-Simulacrum (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 Aug 15, 2018
@gootorov
Copy link
Contributor Author

New smallvec is quite faster, but only when the number of elements is large, otherwise it is about the same as before. It would be interesting to see full perf comparison.

Current smallvec:

test small_vec::tests::fill_small_vec_1_10_with_cap  ... bench:          35 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_1_10_wo_cap    ... bench:          32 ns/iter (+/- 2)
test small_vec::tests::fill_small_vec_1_50_with_cap  ... bench:          40 ns/iter (+/- 2)
test small_vec::tests::fill_small_vec_1_50_wo_cap    ... bench:          37 ns/iter (+/- 4)
test small_vec::tests::fill_small_vec_32_10_with_cap ... bench:          34 ns/iter (+/- 5)
test small_vec::tests::fill_small_vec_32_10_wo_cap   ... bench:          29 ns/iter (+/- 7)
test small_vec::tests::fill_small_vec_32_50_with_cap ... bench:          54 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_32_50_wo_cap   ... bench:          50 ns/iter (+/- 8)
test small_vec::tests::fill_small_vec_8_10_with_cap  ... bench:          36 ns/iter (+/- 1)
test small_vec::tests::fill_small_vec_8_10_wo_cap    ... bench:          32 ns/iter (+/- 2)
test small_vec::tests::fill_small_vec_8_50_with_cap  ... bench:          41 ns/iter (+/- 34)
test small_vec::tests::fill_small_vec_8_50_wo_cap    ... bench:          37 ns/iter (+/- 4)

New smallvec:

test small_vec::tests::fill_small_vec_1_10_with_cap  ... bench:          33 ns/iter (+/- 6)
test small_vec::tests::fill_small_vec_1_10_wo_cap    ... bench:          30 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_1_50_with_cap  ... bench:          43 ns/iter (+/- 5)
test small_vec::tests::fill_small_vec_1_50_wo_cap    ... bench:          34 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_32_10_with_cap ... bench:          14 ns/iter (+/- 1) // Faster
test small_vec::tests::fill_small_vec_32_10_wo_cap   ... bench:           8 ns/iter (+/- 0) // Faster
test small_vec::tests::fill_small_vec_32_50_with_cap ... bench:          38 ns/iter (+/- 5) // Faster
test small_vec::tests::fill_small_vec_32_50_wo_cap   ... bench:          34 ns/iter (+/- 3) // Faster
test small_vec::tests::fill_small_vec_8_10_with_cap  ... bench:          32 ns/iter (+/- 2)
test small_vec::tests::fill_small_vec_8_10_wo_cap    ... bench:          30 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_8_50_with_cap  ... bench:          36 ns/iter (+/- 3)
test small_vec::tests::fill_small_vec_8_50_wo_cap    ... bench:          35 ns/iter (+/- 3)

@Mark-Simulacrum
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Aug 15, 2018

⌛ Trying commit 32a928feb6b6541d9198b09594c3f1e9e051d781 with merge 31e325e55811a6bde18f86114c56f04729c78575...

@bors
Copy link
Contributor

bors commented Aug 15, 2018

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

@gootorov
Copy link
Contributor Author

Rebased.

@arthurprs
Copy link
Contributor

Thanks for this. I think more important than the cycles, it is 4/8 bytes smaller.

@Mark-Simulacrum
Copy link
Member

@rust-timer build 31e325e55811a6bde18f86114c56f04729c78575

@rust-timer
Copy link
Collaborator

Success: Queued 31e325e55811a6bde18f86114c56f04729c78575 with parent 81cfaad, comparison URL.

@bors
Copy link
Contributor

bors commented Aug 19, 2018

☔ The latest upstream changes (presumably #53316) made this pull request unmergeable. Please resolve the merge conflicts.

@gootorov
Copy link
Contributor Author

Rebased.

@Mark-Simulacrum
Copy link
Member

Perf results look fine to me, will try to get a review in sometime today or tomorrow.

@@ -33,6 +33,7 @@ parking_lot = "0.5.5"
byteorder = { version = "1.1", features = ["i128"]}
chalk-engine = { version = "0.7.0", default-features=false }
rustc_fs_util = { path = "../librustc_fs_util" }
smallvec = "0.6.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

We may want to use the union feature here. (smallvec = { version = "0.6.4", features = ["union"] }).

@@ -16,3 +16,4 @@ rustc_target = { path = "../librustc_target" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
log = "0.4"
smallvec = "0.6.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -19,6 +19,7 @@ parking_lot_core = "0.2.8"
rustc-rayon = "0.1.1"
rustc-rayon-core = "0.1.1"
rustc-hash = "1.0.1"
smallvec = "0.6.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

@@ -25,3 +25,4 @@ syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
byteorder = { version = "1.1", features = ["i128"] }
rustc_apfloat = { path = "../librustc_apfloat" }
smallvec = "0.6.4"
Copy link
Contributor

Choose a reason for hiding this comment

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

etc. etc.

@llogiq
Copy link
Contributor

llogiq commented Aug 21, 2018

I'll push a followup PR to this to change SmallCStr to use SmallVec once this is merged. If this gets merged without the union feature, I can add it then.

@gootorov
Copy link
Contributor Author

Addressed review comments.

@Mark-Simulacrum
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Aug 21, 2018

⌛ Trying commit 663e279bf28e024a6367226e7de652b8ab4296f1 with merge 40061cbe688a1db38eea0ba1bff9e2a8dc8c8297...

@bors
Copy link
Contributor

bors commented Aug 21, 2018

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

@Mark-Simulacrum
Copy link
Member

@rust-timer build 40061cbe688a1db38eea0ba1bff9e2a8dc8c8297

@rust-timer
Copy link
Collaborator

Success: Queued 40061cbe688a1db38eea0ba1bff9e2a8dc8c8297 with parent 70c33bb, comparison URL.

@bors
Copy link
Contributor

bors commented Aug 22, 2018

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout use-servo-smallvec (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self use-servo-smallvec --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
warning: Cannot merge binary files: src/Cargo.lock (HEAD vs. heads/homu-tmp)
Auto-merging src/libsyntax/ext/expand.rs
Auto-merging src/libsyntax/ext/base.rs
Auto-merging src/librustc_traits/chalk_context.rs
Auto-merging src/librustc_resolve/macros.rs
Auto-merging src/librustc_mir/lib.rs
Auto-merging src/librustc_mir/borrow_check/mod.rs
Auto-merging src/librustc/ty/walk.rs
Auto-merging src/librustc/ty/mod.rs
Auto-merging src/librustc/traits/query/normalize.rs
Auto-merging src/librustc/traits/query/dropck_outlives.rs
Auto-merging src/librustc/mir/mod.rs
Auto-merging src/librustc/infer/canonical/mod.rs
Auto-merging src/librustc/infer/canonical/canonicalizer.rs
Auto-merging src/librustc/hir/lowering.rs
Auto-merging src/Cargo.lock
CONFLICT (content): Merge conflict in src/Cargo.lock
Automatic merge failed; fix conflicts and then commit the result.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 22, 2018
@gootorov
Copy link
Contributor Author

gootorov commented Aug 23, 2018

Rebased and updated smallvec to 0.6.5. The update was a minor version bump - so no code changes and no need to re-review.

@oli-obk
Copy link
Contributor

oli-obk commented Aug 23, 2018

@bors r=Mark-Simulacrum p=1

@bors
Copy link
Contributor

bors commented Aug 23, 2018

📌 Commit 4d81fe9 has been approved by Mark-Simulacrum

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 23, 2018
@michaelwoerister
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Aug 23, 2018

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Aug 23, 2018

📌 Commit 4d81fe9 has been approved by michaelwoerister

@michaelwoerister
Copy link
Member

oops... double r+. Looks like it's fine though.

@bors
Copy link
Contributor

bors commented Aug 23, 2018

⌛ Testing commit 4d81fe9 with merge e19ef4419f929459104bcf4a295878ad048bbd6b...

@bors
Copy link
Contributor

bors commented Aug 23, 2018

💔 Test failed - status-travis

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-debug 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:18:43] [RUSTC-TIMING] rustc_incremental test:false 67.682
[00:19:13]    Compiling rustc_allocator v0.0.0 (file:///checkout/src/librustc_allocator)
[00:19:52] [RUSTC-TIMING] rustc_allocator test:false 38.568

Broadcast message from root@travis-job-e31137b6-803c-406d-ae8d-b77ac765799c
 (unknown) at 14:17 ...
The system is going down for power off NOW!
[00:21:17] 
[00:21:17] Session terminated, terminating shell... ...terminated.

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 143.
travis_time:start:0bc5004a
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@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 Aug 23, 2018
@michaelwoerister
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 Aug 23, 2018
@bors
Copy link
Contributor

bors commented Aug 23, 2018

⌛ Testing commit 4d81fe9 with merge e5284b0...

bors added a commit that referenced this pull request Aug 23, 2018
Use optimized SmallVec implementation

This PR replaces current SmallVec implementation with the one from the Servo project.

Closes #51640

r? @Mark-Simulacrum
@bors bors mentioned this pull request Aug 23, 2018
@bors
Copy link
Contributor

bors commented Aug 23, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: michaelwoerister
Pushing e5284b0 to master...

@bors bors merged commit 4d81fe9 into rust-lang:master Aug 23, 2018
@gootorov gootorov deleted the use-servo-smallvec branch August 23, 2018 18:11
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.

9 participants