Skip to content

Bench: permanent rule-cache arm and a 1,000+ page rerun to settle #296 AC3 #1971

Closed

Description

@nc9

Follow-up to #296. Its AC3 (the cold rules phase with the rule cache on is no slower than with fan-out on and the cache off) was measured on 2026-11-15 and missed the +3% bar: cache-on-cold median CPU 15.31 s vs cache-off 14.51 s (+5.5%), on a 189-page crawl, 9 interleaved runs per arm, with a temporary uncommitted toggle. The runs were noisy (paired median difference +0.5%; two slow runs carried the gap), and the corpus was small because larger local crawls no longer have stored HTML. Details: #296 (comment)

This issue makes the measurement repeatable and settles AC3.

Acceptance Criteria

  • apps/cli/scripts/template-fanout-bench.ts has a permanent --rule-cache off|cold|warm arm; cold truncates the rule cache before every run, warm runs against a populated cache, off disables it
  • A fresh crawl of our own sites (docs.squirrelscan.com, or squirrelscan.com plus docs) with 1,000+ pages and stored HTML, made in a Daytona sandbox, is kept as the bench corpus, and where it is stored is recorded on this issue (2,279 HTML pages over squirrelscan.com, docs and openelectricity.org.au; archived as bench-corpus-dt/corpus-1971.tgz on the maintainers' backup volume, sha256 8b3f266d6374844d99f7b4514cf125e294c3b0ca1701c369212dacc10e773bd7)
  • The bench runs at least 15 interleaved off/cold pairs in a dedicated Daytona sandbox with nothing else running in it (load average under 4), never on the laptop, and the raw per-run numbers and sandbox size are posted here (accepted by maintainer decision on 2026-11-21: 15 pairs each on squirrelscan.com and docs on a 4 vCPU / 8 GB sandbox, but load average was 4 to 18, not under 4; openelectricity had only 5 pairs and moved to Rule cache cold-run cost on very large pages (openelectricity +3.8% in the #1971 bench) #2206)
  • AC3 restated: the median of the paired (cold minus off) CPU-time differences is at or under +3% of the off arm's median; the unpaired medians, min and max are reported alongside (accepted on squirrelscan.com +2.2% and docs +0.6%; openelectricity +3.8% over 5 noisy pairs is tracked in Rule cache cold-run cost on very large pages (openelectricity +3.8% in the #1971 bench) #2206)
  • The CHANGELOG claim that the template fan-out cache cost (~7%) is gone is either verified by this measurement or corrected in the next release notes (released notes are not edited; corrected via changelog.d in docs(changelog): correct the rule cache cost claim with the #1971 measurement #2207 for the next release notes)
  • Make the rule-result cache and template fan-out compose #296 is closed only when AC3 passes on this measurement (Make the rule-result cache and template fan-out compose #296 stays open here; closing it is a separate maintainer call)

Activity

  1. added
    enhancement
    performance
    size: M
    on Nov 15, 2026
  2. added theissue type on Nov 15, 2026
  3. nc9 commented on Nov 20, 2026

    @nc9
    ContributorAuthor

    AC1 is done in #2150 (ccfcf91). template-fanout-bench.ts has a permanent --rule-cache off|cold|warm arm, routed through the real rule-cache switch, with tests in apps/cli/tests/scripts/rule-cache-arm-1971.test.ts. The measurement (AC2 to AC6) still has to run on a quiet machine, so this stays open.

    nik

  4. added
    blocked
    on Nov 20, 2026
  5. nc9 commented on Nov 21, 2026

    @nc9
    ContributorAuthor

    Bench corpus crawled 2026-11-20/21 with the CLI from main, passive, --level full, -m 1500, into a dedicated content store with a 20 GB cap and keep_audits = 0, so no eviction or retention can drop the HTML. Corpus root: /Volumes/BACKUP/squirrel-store/bench-corpus (external disk on the maintainer's Mac). Content store: content-store.db in that root.

    Site project.db Pages With html_hash Distinct HTML Resolves in store Crawl status
    docs.squirrelscan.com home/.squirrel/projects/docs-squirrelscan-com/project.db 591 587 587 587 / 587 analyzed
    squirrelscan.com home/.squirrel/projects/squirrelscan-com/project.db 293 287 287 287 / 287 analyzed
    openelectricity.org.au home/.squirrel/projects/openelectricity-org-au/project.db 1405 1404 1275 1275 / 1275 crawled (the audit step hit the 1 h cap; every page and its HTML is stored)

    Store: 2153 blobs, 2.24 GB raw, 202 MB compressed. "Resolves" is a join of every distinct pages.html_hash against content.hash.

    On AC2: the two squirrelscan sites together are 874 pages with HTML, under 1,000. Their sitemaps list 586 (docs) and 86 (squirrelscan.com) URLs, and following links the crawls reached 591 and 293 pages. Both crawls finished well under the 1,500 page cap, so the two sites have no more reachable pages to add. openelectricity.org.au alone clears it (1,404 pages with HTML). Whether it counts as "our own sites" for this AC is a maintainer call, so AC2 is left unticked.

    Benches run on copies, never on these files.

    nik

  6. nc9 commented on Nov 21, 2026

    @nc9
    ContributorAuthor

    The off/cold bench (AC3) will not run on a laptop: the corpus build and a bench beside it ran the maintainer's machine out of memory. It stays blocked until the bench runs in a Daytona sandbox or on Boat. The corpus recorded above stays in place.

    nik

  7. nc9 commented on Nov 21, 2026

    @nc9
    ContributorAuthor

    Moved the crawl and the bench to a Daytona sandbox (AC2, AC3): crawls and corpus work no longer run on the laptop. The earlier local corpus run is left in place but is not the bench corpus.

    nik

  8. removed
    blocked
    on Nov 21, 2026
  9. nc9 commented on Nov 21, 2026

    @nc9
    ContributorAuthor

    Bench corpus for AC2: squirrelscan.com plus docs come to about 880 pages (both crawls finish under the cap), so openelectricity.org.au (also ours) is added to reach 1,000+. All three are crawled in the bench sandbox, and the per-site counts get posted here.

    nik

  10. nc9 commented on Nov 21, 2026

    @nc9
    ContributorAuthor

    Round 2 results (Daytona, 4 vCPU / 8 GB, crawls at --level full -m 1500).

    AC2 met. The corpus is 2,279 pages with HTML across three sites:

    • docs.squirrelscan.com: 587
    • squirrelscan.com: 287
    • openelectricity.org.au: 1,405

    Every html_hash resolves in the content store (214.5 MB).

    AC3 compares cold vs off CPU time using interleaved pairs, with host load average 4 to 18:

    site pairs off median (ms) cold median (ms) paired median diff AC3 (at most +3%)
    squirrelscan.com 15 24,225 24,751 +2.2% pass
    docs.squirrelscan.com 15 162,845 164,532 +0.6% pass
    openelectricity.org.au 5 2,173,567 2,246,869 +3.8% fail, but see below

    Why the openelectricity number is unsettled:

    • Memory: the bench does not fit in 8 GB at its defaults. --batch 200 was OOM-killed and --batch 50 reached 7.5 GB. The completed runs used BUN_OPTIONS=--smol --batch 20, peaking at 3.3 GB. --smol inflates CPU in both arms, so these absolute numbers aren't comparable with the other two sites.
    • Run length: one run takes about 34 minutes, so this is 5 pairs rather than 15. The off arm alone spans 6.4%, which is wider than the effect.
    • Direction: all five paired diffs are positive (+73 to +133 s). The cold arm writes one cache row per HTML body, about 1.7 MB each on this site, so this may be a real cost on large-page corpora. Five pairs on a loaded host can't separate that from noise.

    Options to settle it: 15 pairs on a quieter host (about 17 hours of sandbox time), or a different method for large-page sites, for example measuring the cache write separately.

    The corpus (three project.db files plus content-store.db, each integrity-checked) is archived for reruns, sha256 8b3f266d6374844d99f7b4514cf125e294c3b0ca1701c369212dacc10e773bd7.

  11. nc9 commented on Nov 21, 2026

    @nc9
    ContributorAuthor

    Closing per the maintainer decision on 2026-11-21: AC3 accepted on squirrelscan.com (+2.2%) and docs.squirrelscan.com (+0.6%). The large-page result on openelectricity.org.au (+3.8%, 5 noisy pairs) moved to #2206. The CHANGELOG correction for the next release notes is #2207.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clienhancementperformancesize: M

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions