Skip to content

Reset unpinned states and erase hits in NoGcKeepOneExpanderCache. - #336

Merged
copybara-service[bot] merged 1 commit into
mainfrom
copybara/993745190
Oct 6, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
copybara/993745190

Conversation

@copybara-service

Copy link
Copy Markdown

Reset unpinned states and erase hits in NoGcKeepOneExpanderCache.

In NoGcKeepOneExpanderCache::FindOrExpand, once any pinned state (ref_count_ > 0) was moved into cache_, cache_.empty() remained false. When subsequently visiting an unpinned state (ref_count_ == 0) followed by another uncached state, state_ stayed non-null and FindOrExpand returned state_.get() without resetting or expanding the new state, serving stale arcs from the prior unpinned state. In addition, cache hits moved the std::unique_ptr<State> out of cache_ without erasing the map entry, leaving null entries in cache_ indefinitely.

When cache_ hits, move the cached state into state_, erase the map entry, and return immediately. On a cache miss, allocate state_ if null or call state_->Reset() when reusing an unpinned state, then expand the requested state.

@copybara-service
copybara-service Bot force-pushed the copybara/993745190 branch 2 times, most recently from b9bc0e0 to 27967a8 Compare October 6, 2026 17:57
In `NoGcKeepOneExpanderCache::FindOrExpand`, once any pinned state (`ref_count_ > 0`) was moved into `cache_`, `cache_.empty()` remained false. When subsequently visiting an unpinned state (`ref_count_ == 0`) followed by another uncached state, `state_` stayed non-null and `FindOrExpand` returned `state_.get()` without resetting or expanding the new state, serving stale arcs from the prior unpinned state. In addition, cache hits moved the `std::unique_ptr<State>` out of `cache_` without erasing the map entry, leaving null entries in `cache_` indefinitely.

When `cache_` hits, move the cached state into `state_`, erase the map entry, and return immediately. On a cache miss, allocate `state_` if null or call `state_->Reset()` when reusing an unpinned state, then expand the requested state.

PiperOrigin-RevId: 994511676
@copybara-service
copybara-service Bot merged commit df1c76f into main Oct 6, 2026
8 checks passed
@copybara-service
copybara-service Bot deleted the copybara/993745190 branch October 6, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant