Repository navigation
Follow-ups to #105 and #106: walk-cache shared values, never evict a search in use - #107
Merged
Merged
Conversation
A shared value of many small records, such as a meta object of 1,000 records attached to every row, was walked record by record on every store: about 500 steps each, 10 million for 20,000 rows, so the program stopped at the 5,000,000-step budget. The store walk now remembers every object whose whole graph it checked. A leaf stays remembered until an object is stored into it; any other object is remembered for the current epoch, and storing an object into a remembered object that another remembered object holds starts a new epoch. A differential fuzz of 3.9 million stores against a fresh reachability check agrees on all of them and fails at once when the epoch is not advanced. mcp-execute-step-budget: 20,000 rows sharing a 1,000-record meta now complete in 283 ms (TimeoutExceeded at 1,317 ms before); storing a row into that shared value is still rejected as a cycle; runaways still stop with TimeoutExceeded.
…part Kept search orders (#106) had three gaps: - room was checked before the ranking await and eviction after it was strict LRU, so new searches ranking at once evicted searches still in use; an order is now admitted after the await, evicting only searches unread for 30 s, or not kept; - idle time read the wall clock; it now reads the monotonic clock; - a search too large to keep was remembered in the same cache with its key's bytes, and a key past 6 MB evicted every kept search; such searches are now remembered in their own bounded map, and a key too large to keep is never remembered. mcp-search-kept-orders covers the first and third: both assertions fail on the previous store and pass on this one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups to #105 (CodeMode step budget) and #106 (kept search orders), from their reviews. No default changes:
EXECUTOR_MCP_MAX_STEPSstill defaults to 5,000,000, and no workflow files are touched.Why
rejectCircularInsertion) cached only leaves, objects holding no objects. A shared value made of many small records, such as ametaof 1,000 records attached to every row, was walked record by record on every store: about 500 steps each, 10 million for 20,000 rows. A legitimate program stopped at the budget in about 1 s.tool-search-store.ts:room()ran before the ranking await, andkeep()evicted strict LRU after it, so new searches ranking at once evicted searches still being paged. The 30 s idle rule was bypassed.What
Store walk (codemode patch,
references.js). It now remembers every object whose whole graph it checked, not only leaves.insideWalked) starts a new epoch, which drops all non-leaf entries at once.Kept orders.
admit()decides after the ranking, with the order in hand. It evicts only searches unread forkeptIdleMillis; otherwise the order isn't kept. A hit onlytouch()es; it never evicts.Clock.monotonicTimeNanos.oversizedmap, bounded to 32 entries and 2 MB of keys, so they never evict a kept order. A search whose key alone exceedskeptOrderBytesis neither kept nor remembered: each of its pages ranks.keptIdleMillisdoc now says that once 32 searches are each read within 30 s, or their orders fill 6 MB, further walks go uncached until one idles.Proof
All runs were on shuvdev (Linux x64) with Node 24.22.2 and the Bun self-host e2e server.
bun run check: passes (format, lint, typecheck of 9 projects, no-unit-tests, e2e boundary).bun run e2e:self-host --test-name "Hosted MCP execute stops a program|An MCP search without a query pages|A search being paged keeps": 3 passed (3).shared-records-metawithTimeoutExceededafter 1,317 ms (expected { ok: false … } to match object { ok: true, value: 20000 }).expected ['ranked','ordered','ranked','ordered','ordered'] to equal […,'ranked','kept'](the oversized key flushed the cache), and, in 2 of 2 runs,The search being paged keeps its order: expected ['ranked'] to deeply equal ['kept'](the crowd evicted it).mcp-execute-step-budget: 20,000 rows each pushed with a shared 1,000-record meta complete in under 5 s. Storing a row into that shared value is still rejected as a circular value; this case fails when the epoch isn't advanced. The runaway, native, operator, concat and template cases still stop withTimeoutExceeded.mcp-search-kept-orders(new):rankedboth times, and the first search's third page is stillkept.kept.rejectCircularInsertionagainst a fresh reachability check. Over 8 seeds it ran 3.9 M stores and 1.85 M cycles with 0 mismatches. Mutants fail at once: no epoch bump, noinsideWalkedmark, or the epoch check ignored.Perf
Step-budget e2e, Bun self-host server, ms:
while(true)g[k] = g[k] || []In-process Node 24,
CodeMode.executewith 5 M steps, ms:rows.push({ id, meta })× 20k, 1,000-record metar.meta = meta× 20krows[i] = rafterr.meta = metameta.records[k]before each push (documented)while (true) n++or-pushmcp-search-walkis unchanged: 3,539 ms for the first walk, 473 ms for the repeat.Not in this PR (backlog)
o.x++on big valuesObject.fromEntriesClock.currentTimeMillisforClock.monotonicTimeNanosin the two idle reads.No prod deploy: that needs a separate sign-off.