Skip to content

perf: skip the cycle walk for inserted values that hold no objects, and list own keys in one pass - #74

Merged
kommander merged 1 commit into
devfrom
perf/cycle-check-and-own-keys
Nov 25, 2026
Merged

kommander merged 1 commit into
devfrom
perf/cycle-check-and-own-keys

Conversation

@kommander

Copy link
Copy Markdown
Contributor

The cycle check that runs on every push, unshift, splice, fill, Object.assign and object element/property write skips its walk when the inserted value is a plain object or array holding no objects or accessors; ownKeys lists keys in one pass instead of three spreads and four filters. Behaviour is unchanged: cycles through push, index and property writes are still rejected.

Timing, dev 3da1858 vs this PR, under the shared timing lock at load 3.5–4.7 (medians, µs per run):

program (20,000 iterations) dev PR
a.push({ i }) 7742 2614
a[i] = { i } 8680 3574
a.push(i) 2336 1462
a = { i } (no insertion) 1443 1296
  • Code Mode corpus (435 programs, 3 alternating passes): geometric mean ×0.972, none >5% slower in every pass; heaviest win 28.3 → 11.2 ms.
  • Code Mode return 1: 160.0 → 161.5 µs (noise); a.push({ i }) through Code Mode: 8197 → 2454 µs.
  • bun run check (incl. round-trip) passes; the Code Mode correctness diff over the same corpus is identical (0 of 436 programs changed).

@kommander
kommander merged commit 28fb1d6 into dev Nov 25, 2026
1 check passed
@kommander
kommander deleted the perf/cycle-check-and-own-keys branch November 25, 2026 10:28
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