GentleGraph

Measured diagnosis · Performance

Cold impact queries time out before they start working

A cold impact query answers unknown on projects of fifty files. The budget was never the problem. The budget was measuring the wrong thing.

Commit 0c286bf Measured 2026-11-28 Repository Gentle-Graph

Author CODY · Senior Architect · _00 team Language en Leer en español

Verdict. Loading the engine alone costs 1428–1480 ms. The budget is 1500 ms and it also has to cover process startup, Git subprocesses and the query itself. The query is not slow: it is not given the chance to begin.

Summary

Three causes, one root

A cold impact query returns { mode: "unknown", indexed: null, partial: true } on repositories as small as 50 files. The 1500 ms budget in lib/gentle-graph/query-session.ts covers four separate costs at once. Engine module evaluation alone consumes almost all of it, so the query often gives up before it begins to index.

With the budget raised in a throwaway copy, the same queries complete successfully in 887–1765 ms. This is not a correctness defect. It is a budget that does not match the work it is meant to bound.

1472 ms Engine module evaluation, repeated with the files already in the OS cache
1500 ms The whole budget, for startup, Git, indexing and the query
1088 ms Elapsed time to query a project of three files
46% Extra time for a project 185 times larger: 3 files vs 555

The three causes

Separated, and weighed

  1. Root cause

    Design: one budget for four costs

    query-session.ts starts a 1500 ms timer; query-worker.ts sets an internal deadline of 1450 ms to answer before the parent gives up. Inside that single window sit process start, module evaluation, Git subprocesses and the query itself.

    Module evaluation dominates, and it is not disk cache: repeating the import with files already cached still measured 1472 ms. The cost is evaluating the module graph. No single module can be blamed either — measured independently, each one costs 883 to 1935 ms, so loading any of them alone consumes what the whole budget allows.

  2. Threshold

    Calibrated without separating startup from work

    File count barely moves the result. Three files cost 1088 ms; 555 files cost 1593 ms. A 185-fold difference in project size changes the elapsed time by 46%. The budget is paying for startup, not for the graph.

  3. Aggravating factor

    Hardware, which makes it worse but did not cause it

    The measurements were taken on an Intel Core i3-6006U (4 threads) with a load average between 16 and 20, oversubscribed four to five times. On an idle machine the same work would probably fit inside 1500 ms and still have no margin, because startup alone consumes most of the budget.

Evidence

Size is not what costs

Each repository below was generated for the test, with the worker closed before every run, so every measurement is a genuine cold start.

Cold impact query, three runs per project size, in milliseconds
Files Run 1 Run 2 Run 3 Median
3 1212 1088 887 1088
50 1738 1566 1308 1566
555 1593 1265 1765 1593

The clearest signal that the timeout is not a measurement: on every run that fails, elapsed time lands at 1502–1530 ms. That is the timer cutting, not the engine finishing.

It is also why the failure is intermittent rather than constant. Two consecutive full-suite runs on the same checkout produced 73/73 and 72/73. An intermittent defect in CI is worse than a deterministic one: nobody investigates it, and everyone learns to re-run the job.

Effect

A plausible answer to the wrong question

The degradation is silent and semantically false. mode: "unknown" together with partial: true reads as “no results” to a reasonable consumer, not as “gave up”. A caller cannot distinguish an empty answer from a surrender, so it never retries and never widens its search.

Proposal

Fix the shape, not the number

  1. Make the budget a work budget, not a process budget

    Start the timer after the engine is loaded and the worker is ready, so startup cannot consume the allowance meant for indexing.

  2. Report startup and work separately

    Use the graphProfile timestamps the worker already emits for scope and reply. No new instrumentation is needed.

  3. Make unknown distinguishable from “no results”

    A consumer must be able to retry instead of reading a false negative.

Raising the number alone would hide the symptom. The cost is startup, so cold queries would keep brushing against whatever new limit is chosen.

Reproduction

Deterministic, and not dependent on the machine

# Generate a repository of N files, close the worker before each run
git init -q .
for i in $(seq 1 50); do echo "export function f$i() {}" > f$i.ts; done
printf 'import { helper } from "./support";\nexport function targetFn() { return helper(); }\n' > billing.ts
echo 'export function helper() {}' > support.ts
git add . && git commit -qm fixture

Then call sessionQueryDetails({ kind: "impact", root, term: "targetFn" }) and closeQuerySessions() between runs. Reproduced on pristine main extracted with git archive into a temporary directory, both with and without node_modules.

The failing test is reports cold query telemetry and finds an untracked consumer in a fresh worktree in tests/gentle-graph.test.ts, which asserts mode === "jit". It is intermittent, so a single green run does not clear it.

Scope of this report

What it does not claim

Stated limits

  • The numbers come from one oversubscribed machine and are therefore an upper bound, not a typical case. The design conclusion does not depend on them: startup alone exceeds the budget even at the lowest measurement.
  • scripts/bench-jit.mjs enforces coldGuideMs: 150 and architectureMs: 15. Both fail on pristine main as well, with cold guide p95 at 458–656 ms. That is a separate defect: a contribution gate that blocks visibly, rather than production behaviour that degrades silently.
  • No fix is proposed for either defect in this document, and nothing in the engine was changed to produce these measurements beyond a temporary budget increase in a throwaway copy.