Skip to content

fix(memo): preserve table nodes across global invalidation - #16075

Merged
rgrinberg merged 2 commits into
ocaml:mainfrom
rgrinberg:push-nqzvuxnqrttk
Aug 29, 2026
Merged

rgrinberg merged 2 commits into
ocaml:mainfrom
rgrinberg:push-nqzvuxnqrttk

Conversation

@rgrinberg

Copy link
Copy Markdown
Member

Follow up on #16068 by removing the table eviction that originally made global Memo invalidation unsafe. Eviction breaks the canonical input-to-node mapping: lazy nodes can retain and recompute an evicted node, while later table lookups create and invalidate a disconnected replacement.

Keep table entries in place and invalidate their nodes instead. This preserves node identity while still forcing every cached computation to recompute. Rename the operation from clear_caches to invalidate_caches to reflect its semantics.

Related to #16052.

Retain a memo table node through a lazy node, clear all caches, and show that a
later table lookup invalidates a different node while the retained value stays
stale.

Refs ocaml#16052

Signed-off-by: Rudi Grinberg <[email protected]>
Invalidate cached nodes without removing them from their tables. This keeps one
canonical node per input so references retained through lazy nodes remain
connected to later table invalidations. Rename the global operation to describe
its invalidation semantics.

Refs ocaml#16052

Signed-off-by: Rudi Grinberg <[email protected]>
@rgrinberg
rgrinberg merged commit 05ab9f8 into ocaml:main Aug 29, 2026
38 of 39 checks passed
@Alizter Alizter added this to the 3.25.0 milestone Aug 30, 2026
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