10

Arena: use specialization to avoid copying data by bugadani · Pull Request #7856...

 3 years ago
source link: https://github.com/rust-lang/rust/pull/78569
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Arena: use specialization to avoid copying data #78569

Conversation

Contributor

bugadani commented on Oct 30

edited

In several cases, a Vec or SmallVec is passed to Arena::alloc_from_iter directly. This PR makes sure those cases don't copy their data unnecessarily, by specializing the alloc_from_iter implementation.

Collaborator

rust-highfive commented on Oct 30

r? @varkor

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

Contributor

Author

bugadani commented on Oct 30

cc @est31

Member

varkor commented on Nov 16

Apologies for taking so long; this slipped under my radar. I'm not familiar with this code, so I'm assigning to @Mark-Simulacrum based on git blame.

r? @Mark-Simulacrum

bugadani

force-pushed the

bugadani:arena-spec

branch 4 times, most recently from 599683e to 43b83b3

on Nov 19

Contributor

Author

bugadani commented on Nov 20

@Mark-Simulacrum I've done what I could. I've addressed your comments and reverted some changes based on those comments. For example, changes to write_from_iter are no longer part of this PR, as they aren't necessary any more.

Member

Mark-Simulacrum commented on Nov 21

@bors try @rust-timer queue

This should just be a win (or roughly neutral), but let's check. r=me otherwise.

Collaborator

rust-timer commented on Nov 21

Awaiting bors try build completion

Contributor

bors commented on Nov 21

hourglass Trying commit 43b83b3 with merge aa21b48...

Contributor

bors commented on Nov 21

sunny Try build successful - checks-actions
Build commit: aa21b48 (aa21b48c4d75183274998a446bae14e98053637a)

Collaborator

rust-timer commented on Nov 21

Collaborator

rust-timer commented 29 days ago

Finished benchmarking try commit (aa21b48): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never
@rustbot modify labels: +S-waiting-on-review -S-waiting-on-perf

Contributor

Author

bugadani commented 29 days ago

Interesting. I wonder if I see the results correctly - an increase in instruction counts, but in the same time, looking at the detailed results, a decrease in times? For example, this report belongs to a 0.5% instruction count regression, but shows a -0.3% total time diff: https://perf.rust-lang.org/detailed-query.html?commit=aa21b48c4d75183274998a446bae14e98053637a&base_commit=c9c57fadc47c8ad986808fc0a47479f6d2043453&benchmark=match-stress-enum-check&run_name=incr-unchanged

I would say that this is perhaps a slight regression in instruction counts, but overall a win on cycles -- https://perf.rust-lang.org/compare.html?start=c9c57fadc47c8ad986808fc0a47479f6d2043453&end=aa21b48c4d75183274998a446bae14e98053637a&stat=cycles%3Au on non-incremental benchmarks. I am inclined to land it based on these performance results; it does not seem like an obvious win yet, but it does seem like something we should be doing to try and avoid potential problems for the cases optimized here.

Ok, r=me with commits squashed

Contributor

bors commented 29 days ago

pushpin Commit e93a463 has been approved by Mark-Simulacrum

Note that the 50% there is a wall clock measurement of 6ms, which is almost certainly noise. Cycle measurements frequently have noise in the 5% range on clean benchmarks; for incremental unchanged benchmarks they can be even noisier since there's less overall cycles on those.

I am not particularly worried.

Contributor

est31 commented 29 days ago

@Mark-Simulacrum thanks for the info!

Contributor

bors commented 29 days ago

hourglass Testing commit e93a463 with merge 432d116...

Contributor

bors commented 29 days ago

sunny Test successful - checks-actions
Approved by: Mark-Simulacrum
Pushing 432d116 to master...

bors

merged commit 432d116 into rust-lang:master 29 days ago

11 checks passed

rustbot

added this to the 1.50.0 milestone

29 days ago

Collaborator

rust-highfive commented 29 days ago

mega Toolstate changed by #78569!

Tested on commit 432d116.
Direct link to PR: #78569

broken_heart rls on linux: test-pass → test-fail (cc @Xanewok).

mem::forget(self);

slice::from_raw_parts_mut(start_ptr, len)

}

}

pickfire 19 days ago

Contributor

Looks like there are quite a bit of code duplication here, shouldn't it be refactored?

bugadani 19 days ago

Author

Contributor

Well, it's not intentionally duplicated, but I couldn't find a way to make it significantly nicer. Unfortunately, we can't use alloc_from_slice because it requires the items to be Copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects

None yet

Milestone

1.50.0

Linked issues

Successfully merging this pull request may close these issues.

None yet

10 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK