Skip to content

perf(safe-js): reuse unchanged intrinsic retained roots - #717

Closed
kamilio wants to merge 1 commit into
mainfrom
codex/safe-js-retained-roots
Closed

perf(safe-js): reuse unchanged intrinsic retained roots#717
kamilio wants to merge 1 commit into
mainfrom
codex/safe-js-retained-roots

Conversation

@kamilio

@kamilio kamilio commented Sep 10, 2026

Copy link
Copy Markdown
Member

SafeJS repeatedly rebuilds the same intrinsic root-reference lists during memory reconciliation, including every replay segment. This change reuses those lists while every object in the group has a tracked property table and nothing has changed. Nested values are still recursively measured on every reconciliation; memory, step, and replay deadlines are unchanged.

Successful property/prototype mutations and baseline completion invalidate the lists. Restored or otherwise untracked tables retain the conservative scan. Callback snapshots remain stable and releasing a budget removes its retained source.

Validation:

  • Six new regressions cover reuse with nested memory-limit rejection, descriptors/accessors, deletion, prototypes, baseline completion, restored aliases, failed mutations, multiple budgets, and callback snapshots.
  • 248 focused accounting and snapshot tests passed; the maintained agent-harness build closure passed across 24 workspaces.
  • The unchanged Node20 coverage-demo replay passed in 1.29 seconds under its original five-second deadline. This is a local result, not a CI performance guarantee.
  • Independent source review cleared the exact two-file diff. Focused test typing and repository ESLint passed (10,590 files, zero errors/warnings).

This is a separate prerequisite for the replay timeout observed in PR715 and PR716. It is not included in the frozen safe-bash536 consumer build and does not address the independent tiny-MCP compiler-test timeout.

Hosted CI at this head

Node22 and packed public API checks passed. The shared Node20 job still failed the original five-second coverage-demo replay test, so the local improvement does not establish that the hosted deadline is resolved. The same job also reported the tiny-MCP NodeNext DOM deadline and the browser-fixture/Array.fromAsync compatibility failures owned by separate prerequisites. The provider E2E and external review automation failed their existing model/setup paths. No deadlines or accounting checks were relaxed, and no paid rerun was requested. This PR remains a draft while those failures are addressed.

Saved local verification evidence

This non-UI diagnostic was rendered from saved local logs for head 344ddf40439da30819085a58d8bc94a8f301bda7 and captured with Playwright CLI. It records the reference-reuse RED case, 248 passing accounting/snapshot tests, the original focused replay test passing in 1.29 seconds under its unchanged five-second deadline, and saved build/type/lint results. It is not a product interaction or a fresh benchmark run; local results do not establish hosted CI timing.

Saved local retained-root verification results

Cache only collected root references for groups backed entirely by tracked
property tables. Successful property/prototype changes and baseline completion
invalidate the cache; untracked and restored tables retain conservative scans.
Nested values are still recursively measured on every reconciliation.

Validation: 248 focused accounting/snapshot tests; maintained 24-workspace
agent-harness build closure; unchanged five-second Node20 coverage-demo replay
passed in 1.29s. Six new regressions cover allocation reuse, nested budget
failure, descriptor/prototype changes, rejected mutations, restored aliases,
and retained callback snapshots. Focused test typing and ESLint gate this commit.

### Tests Added

| Test | Verifies |
| --- | --- |
| reuses the collected roots while still rejecting nested growth above the memory limit | Reference reuse preserves recursive budget rejection |
| refreshes collected roots after define, delete, accessors, prototype changes and baseline completion | Successful mutations invalidate root collection |
| remeasures mutations through an untracked restored property-table alias | Restored aliases keep conservative scanning |
| keeps committed roots after failed definitions and deletions | Rejected mutations preserve committed state |
| keeps both budgets current and ignores rejected prototype mutations | Shared objects invalidate each live budget correctly |
| keeps root snapshots stable when a retained callback mutates the next collection | Callback mutation affects the next capture without changing prior snapshots |
@kamilio

kamilio commented Sep 10, 2026

Copy link
Copy Markdown
Member Author

Cherry-picked retained intrinsic roots caching once as 440d4ef; avoided its duplicate in #715.

Verified on remote main at 4da2a66 after local validation and final installed-package qualification. Closing after cherry-pick/reconciliation rather than merging obsolete branch history.

Release is in progress: https://github.com/poe-platform/poe-code/actions/runs/34500155547 ; scoped packages: https://github.com/poe-platform/poe-code/actions/runs/34500155125 .

@kamilio kamilio closed this Sep 10, 2026
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