Skip to content

perf: stop re-reading children in three model walks - #72

Merged
mikhalchankasm merged 2 commits into
mainfrom
codex/walks-read-once
Sep 24, 2026
Merged

mikhalchankasm merged 2 commits into
mainfrom
codex/walks-read-once

Conversation

@mikhalchankasm

Copy link
Copy Markdown
Owner

What

Three plugin walks stop re-reading the same children. Every result stays as it is.

  • hide_unselected: the hide walk stops at selected items. Before, it descended through each selected subtree a second time, although nothing below a selected item can be hidden: the keep set already holds all of it. The keep set, its count, the hide list and its order, and the root summaries are unchanged.
  • clash_bbox_pair_plan's refine step (refineDepth 1 or 2): children are read once into a list. Before, the code read item.Children three times, one of them a full Count(). This is the same pattern as perf(isolate): enumerate each item's children once #66.
  • The panel's Select Siblings (not an MCP tool): parents are now deduplicated by ModelItem identity, in first-seen order. Before, k selected siblings under one parent re-read that parent's children k times, which is O(n^2). The resulting selection holds the same items.

These three were found by a static audit (Codex, read-only, 569 s) of every child and descendant enumeration in NavisHelper/. The curator confirmed each in the code. The audit's other findings (root-candidate details beyond the cap, the name-filter order in the clash matrix, the path-ambiguity replay, and a dormant panel) touch response contracts or are unreachable today, so they are left out.

L3: hide_unselected, two builds, interleaved, fresh process per arm

Setup: 6513.nwd, model root selected (41 016 items), apply=false, five calls per arm.

round build ms, calls 1 to 5
1 main 3548cf0 3312, 4890, 5079, 3177, 6383
1 this PR 932, 2609, 4379, 6142, 906
2 this PR 966, 2612, 4354, 6369, 900
2 main 3548cf0 3678, 5489, 5614, 3410, 6606
  • Every call returned identical counts: 41 016 kept, 0 hidden, 1 selected.
  • The first call in a fresh process went from 3.3–3.7 s to 0.9–1.0 s.
  • The builds are 1 595 904 and 1 596 416 bytes, and the host-reported write times match each build.
  • Both builds still slow down call after call and recover only after a forced collection. HeavyWorkCollectionPolicy counts generation-0 collections, and this tool makes about 41 000 wrappers with little managed memory each, so the threshold is reached only every three or four calls. This PR does not fix that. It is recorded in the baseline as the next task.

The refine step and Select Siblings were not measured live. The refine step needs a clash pair setup; Select Siblings is a panel command, out of MCP's reach. Both are output-equivalent by construction.

Provenance

  • 7f06ee9: Codex (gpt-6-sol, high effort) wrote it from a 1.2 KB brief and a context file (147 s, main checkout untouched).
  • 993f96e: the curator recorded the measurement and the finding in docs/MCP_TOOL_BASELINE.md.

Verification

  • The acceptance script ended ALL PASS on the head, rerun by the curator. It checks:
    • the refine step reads item.Children once, has no Count(), and iterates a list;
    • CollectItemsToHide takes the selected set and returns before descending into it;
    • Select Siblings collects distinct parents through a HashSet<ModelItem>;
    • each change carries a comment;
    • scope is limited to these files;
    • the full suite passes (1811), tools/list is unchanged, and the guards pass.
  • L2: MSBuild in all four configurations, 0 warnings, 0 errors, for both builds.
  • L3: the table above. The live bundle was checked against its snapshot before the run and restored byte for byte after it (46 files).

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T02:03:21.930754Z 993f96e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mikhalchankasm
mikhalchankasm merged commit 9d99c58 into main Sep 24, 2026
2 checks passed
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