Skip to content

Fix(Processes): Make subterm hoisting deterministic across processes - #422

Open
wjrforcyber wants to merge 2 commits into
egraphs-good:mainfrom
wjrforcyber:fix/deterministic-subterm-hoisting
Open

Fix(Processes): Make subterm hoisting deterministic across processes#422
wjrforcyber wants to merge 2 commits into
egraphs-good:mainfrom
wjrforcyber:fix/deterministic-subterm-hoisting

Conversation

@wjrforcyber

Copy link
Copy Markdown

Issue

serialize() output (and the internal $__expr_N let-numbering / e-class ids) differ between processes for byte-identical input programs.

_exprs_multiple_parents() traversed the expression graph with a set of TypedExprDecl objects and .pop()ed from it. Popping from a set of objects follows id()-based hashing — i.e. memory addresses — so the traversal order (and with it the order/decision in which shared subterms were hoisted into $__expr_N let-bindings) varied per process. Identical programs were therefore lowered into different (equivalent) e-graphs.

Fix

Traverse with a deterministic LIFO worklist (list + .pop(), children via .extend()) instead of a set.

Test

Builds an expression with many shared (multi-parent) subterms, lowers it in 3 fresh subprocesses, and asserts the serialized output hash is identical.

@codspeed-hq

codspeed-hq Bot commented Sep 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing wjrforcyber:fix/deterministic-subterm-hoisting (c33c4f1) with main (6b2016e)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

1 participant