Skip to content

Fix race in MemoTableTypes #912

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 1 commit into from
Jun 12, 2025

Conversation

ibraheemdev
Copy link
Contributor

@ibraheemdev ibraheemdev commented Jun 11, 2025

Noticed this while reading the code. boxcar::Vec::count does not guarantee that there are N contiguous entries initialized, which the current code is assuming. It seems fine to just spin here because, from what I understand, MemoTableTypes is only setup the first time a query is called? I also don't think we've ever seen this bug in practice.

Copy link

netlify bot commented Jun 11, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit c8db064
🔍 Latest deploy log https://app.netlify.com/projects/salsa-rs/deploys/6849fe07decad60008eac84b

@ibraheemdev ibraheemdev force-pushed the ibraheem/memo-types-race branch from c07dd97 to c8db064 Compare June 11, 2025 22:07
Copy link

codspeed-hq bot commented Jun 11, 2025

CodSpeed Performance Report

Merging #912 will not alter performance

Comparing ibraheemdev:ibraheem/memo-types-race (c8db064) with master (09627e4)

Summary

✅ 12 untouched benchmarks

while memo_ingredient_index >= self.types.count() {
self.types.push(MemoEntryType {
data: OnceLock::new(),
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the case that the latest entry has been claimed but is still being initialized, this loop would previously spin waiting for the entry to be initialized while rapidly creating new values, so the new spin loop should be strictly better.

@Veykril Veykril added this pull request to the merge queue Jun 12, 2025
Merged via the queue into salsa-rs:master with commit 04053c1 Jun 12, 2025
12 checks passed
@github-actions github-actions bot mentioned this pull request Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants