Skip to content

Optimize Vec::push#39

Merged
ibraheemdev merged 1 commit into
masterfrom
optimize-push
Aug 13, 2025
Merged

Optimize Vec::push#39
ibraheemdev merged 1 commit into
masterfrom
optimize-push

Conversation

@ibraheemdev

Copy link
Copy Markdown
Owner

This significantly improves the codegen of Vec::push.

Comment thread src/buckets.rs

// If we are close to the end of this bucket, we eagerly allocate the next one to reduce
// later contention.
if location.entry == location.bucket_len.get() / 8 * 7 {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@SabrinaJewson is there a reason you changed the math here? This seems to result in an extra instruction, on x86 at least.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That aws an oversight on my part, sorry 😅. Was just rewriting it to my understanding of what the code did, but didn’t check if that understanding was correct.

@ibraheemdev
ibraheemdev merged commit 886249e into master Aug 13, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants