Commit 32ed149
authored
perf(optimizer): skip redundant hash invalidation in simplify's pointer-reset loop (#7725)
_simplify's post-order pass re-anchors every child's parent/arg_key/index
pointers via set(), which also clears cached structural hashes up the
ancestor chain. The loop never changes values (it rewrites args[k] with
itself), and actual mutations already invalidate at mutation time through
set/replace/pop, so the only effect of the extra invalidation was forcing
while_changing to rehash entire condition subtrees after every (mostly
no-op) pass to detect the fix point.
Fix pointers directly with _set_parent, preserving set(k, None)'s
arg-removal semantics. Simplify step ~5-12% faster across condition and
TPC fixtures; output is byte-identical.1 parent 9e4b3d1 commit 32ed149
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
699 | 699 | | |
700 | 700 | | |
701 | 701 | | |
702 | | - | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
703 | 707 | | |
704 | | - | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
705 | 712 | | |
706 | 713 | | |
707 | 714 | | |
| |||
0 commit comments