Sitelet https://github.com/starkware-libs/cairo/pull/10190
Skip to content

(bug fix): key syntax node child index by kind for stable node ids - #10190

Merged
eytan-starkware merged 1 commit into
mainfrom
eytan_graphite/syntax-child-index-kind-fix
Jul 7, 2026
Merged

eytan-starkware merged 1 commit into
mainfrom
eytan_graphite/syntax-child-index-kind-fix

Conversation

@eytan-starkware

@eytan-starkware eytan-starkware commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Restores kind to both the child-occurrence counter and SyntaxNodeId::Child, so a node's stable id no longer shifts when a different-kind sibling is inserted or removed.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

SyntaxNodeId::Child's per-sibling index is part of a node's salsa identity. #9555 dropped kind from the key used to count child occurrences, so siblings of different kinds sharing (usually empty) key_fields were counted together — contradicting the documented per-(parent, kind, key_fields) invariant.

As a result, inserting or removing a different-kind sibling shifts an unchanged node's index, churning its stable id and defeating salsa early cutoff. The wasted re-execution scales with list size.


What was the behavior or documentation before?

Child occurrences were counted by (parent, key_fields) only. Siblings of different kinds with the same (empty) key_fields shared a counter, so an unchanged node's index — and thus its SyntaxNodeId — could shift when a different-kind sibling was added or removed, invalidating its salsa cutoff.


What is the behavior or documentation after?

kind is part of the occurrence counter and of SyntaxNodeId::Child again, matching the documented per-(parent, kind, key_fields) invariant. A node's stable id is now unaffected by insertion/removal of different-kind siblings.


Related issue or discussion (if any)

Regression from #9555. Part of a stack with #10189 (regression benchmark) and #10191 (relative offsets, which depends on these stable ids to be effective).


Additional context

Measured on the ls_reexec structural-edit scenario added in #10189.

eytan-starkware commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@cursor

cursor Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches core syntax-tree identity and def-cache child matching; behavior change is intentional but affects incremental compilation and cached crate blobs.

Overview
Fixes unstable salsa node ids when different-kind siblings share the same key_fields (a regression from dropping kind from the child counter).

SyntaxNodeId::Child again stores kind, and get_children_impl assigns the chronological index per (parent, kind, key_fields) instead of (parent, key_fields). Unchanged nodes keep the same id when only a different-kind sibling is added or removed, so incremental cutoff is not blown away by spurious re-execution.

Def cache serialization follows the same shape: child ids read kind from SyntaxNodeId when saving and when re-matching children on load, instead of inferring kind from the live syntax node.

Reviewed by Cursor Bugbot for commit 711e476. Bugbot is set up for automated code reviews on this repo. Configure here.

@orizi orizi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@orizi reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).

@eytan-starkware
eytan-starkware changed the base branch from eytan_graphite/ls-reexec-structural-scenario to main July 7, 2026 10:07
SyntaxNodeId::Child's per-sibling index is part of a node's salsa identity. #9555 dropped kind from the key used to count child occurrences, so siblings of different kinds sharing (usually empty) key_fields were counted together, contradicting the documented per-(parent, kind, key_fields) invariant. Inserting or removing a different-kind sibling then shifts an unchanged node's index, churning its stable id and defeating salsa early cutoff; the wasted re-execution scales with list size. Restore kind to both the occurrence counter and SyntaxNodeId::Child.
@eytan-starkware
eytan-starkware force-pushed the eytan_graphite/syntax-child-index-kind-fix branch from 8be9353 to 711e476 Compare July 7, 2026 13:45
@eytan-starkware
eytan-starkware added this pull request to the merge queue Jul 7, 2026
Merged via the queue into main with commit e7b4be3 Jul 7, 2026
55 checks passed
@eytan-starkware
eytan-starkware deleted the eytan_graphite/syntax-child-index-kind-fix branch July 20, 2026 10:59
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.

3 participants