Skip to content

Fix and fuse vec::Iter#33

Merged
ibraheemdev merged 2 commits intomasterfrom
fused-iter
Jun 11, 2025
Merged

Fix and fuse vec::Iter#33
ibraheemdev merged 2 commits intomasterfrom
fused-iter

Conversation

@ibraheemdev
Copy link
Owner

Currently vec::Iter stops if it yields vec.count() elements. This is incorrect in that it may not yield elements whose initialization was synchronized on the creation of the iterator, as we may read an out-of-date vec.count() while also have yielded an element that we didn't expect to (one that was concurrently initialized in-between elements that we meant to have yielded). This PR simplifies the iterator semantics and makes it completely fused on creation, whereas it previously may have continued to yield elements as they were added. I also simplified the implementation which may slightly hurt performance, but I think this will be fixed by #31 anyways (which from a cursory look correctly handles these issues). This also fixes another bug where the index was not updated if we skip over an uninitialized bucket, though that would be extremely rare.

I think this was the underlying cause of astral-sh/ty#115 (comment), because Salsa relies on the iterator being linearizable, in particular, vec.push(x); vec.iter().find(x).is_some(); should never fail.

@ibraheemdev ibraheemdev added the bug Something isn't working label Jun 11, 2025
@ibraheemdev ibraheemdev merged commit 63448e5 into master Jun 11, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments