Skip to content

Remove fast path in reallocation for same layout sizes #75621

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 2 commits into from
Aug 18, 2020

Conversation

TimDiekmann
Copy link
Member

r? @Amanieu

Before merging a perf-run should be done.

Closes rust-lang/wg-allocators#70

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 17, 2020
@Lonami
Copy link
Contributor

Lonami commented Aug 17, 2020

Typo nit:

-// If `new_size` is zero, than `old_size` has '…
+// If `new_size` is zero, then `old_size` has '…

@TimDiekmann
Copy link
Member Author

Thanks :)

@Amanieu
Copy link
Member

Amanieu commented Aug 17, 2020

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Collaborator

bors commented Aug 17, 2020

⌛ Trying commit c619b36 with merge da66a9e07441aed971b868d823aef30f0be216e7...

@TimDiekmann
Copy link
Member Author

Is homu broken? The queue does not show this PR.

@Amanieu
Copy link
Member

Amanieu commented Aug 17, 2020

@bors try

@bors
Copy link
Collaborator

bors commented Aug 17, 2020

⌛ Trying commit c48f784 with merge 4e9d2055704b5bcf1e6dae96a5145640b3bab32c...

@bjorn3
Copy link
Member

bjorn3 commented Aug 17, 2020

It does show it for me.

@Amanieu
Copy link
Member

Amanieu commented Aug 17, 2020

I think it gets canceled if you push to the branch.

@TimDiekmann
Copy link
Member Author

TimDiekmann commented Aug 17, 2020

Didn't noticed you have approved before I have corrected the typo.

@bors
Copy link
Collaborator

bors commented Aug 17, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 4e9d2055704b5bcf1e6dae96a5145640b3bab32c (4e9d2055704b5bcf1e6dae96a5145640b3bab32c)

@rust-timer
Copy link
Collaborator

Queued 4e9d2055704b5bcf1e6dae96a5145640b3bab32c with parent 8cdc94e, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (4e9d2055704b5bcf1e6dae96a5145640b3bab32c): 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

@Amanieu
Copy link
Member

Amanieu commented Aug 17, 2020

Seems like a minor speed boost (up to 0.6%).

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 17, 2020

📌 Commit c48f784 has been approved by Amanieu

@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 17, 2020
@bors
Copy link
Collaborator

bors commented Aug 18, 2020

⌛ Testing commit c48f784 with merge edd08637821fc8e3860b1f6057ac394a9b638532...

@tmandry
Copy link
Member

tmandry commented Aug 18, 2020

@bors retry
yielding to rollup

@bors
Copy link
Collaborator

bors commented Aug 18, 2020

⌛ Testing commit c48f784 with merge 515c9fa...

@@ -209,16 +209,14 @@ unsafe impl AllocRef for Global {
);

// SAFETY: `new_size` must be non-zero, which is checked in the match expression.
// If `new_size` is zero, then `old_size` has to be zero as well.
// Other conditions must be upheld by the caller
Copy link
Member

Choose a reason for hiding this comment

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

This is not documented though, is it? It least grow does not have a comment explaining the caller obligations.

Looks like new_size >= old_size would have to be among those.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a safety constraint, that new_size must be greater than or equal to old_size. If old_size is non-zero (was checked just before), new_size can't be zero.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have a commit ready to be pushed, which cleans up the implementations and documentation of AllocRef a bit, so those things get more clear. The unsafe should be moved to line 217 instead. The match arm, where layout.size() == 0 does not need unsafe at all.

Copy link
Member

@RalfJung RalfJung Aug 18, 2020

Choose a reason for hiding this comment

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

Right, my only comment is that this is an undocumented safety constraint -- at least when looking just at the grow function, and not at the entire file.

EDIT: well, there is a debug assertion. But the usual comment explaining to the caller what they have to uphold is missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

However, I didn't want to change implementations much in this PR because of the perf-run.

Copy link
Member Author

Choose a reason for hiding this comment

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

But the usual comment explaining to the caller what they have to uphold is missing.

This is stated in the safety-section of the trait.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see... in GH I couldn't see that this is a trait impl. Sorry.

Copy link
Member Author

Choose a reason for hiding this comment

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

No Problem!
In any case #75657 should make this more readable if you only read the code. :)

@bors
Copy link
Collaborator

bors commented Aug 18, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: Amanieu
Pushing 515c9fa to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 18, 2020
@bors bors merged commit 515c9fa into rust-lang:master Aug 18, 2020
@TimDiekmann TimDiekmann deleted the no-fast-realloc branch August 18, 2020 07:49
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Make safety constraints for grow and shrink more strict
10 participants