# Crawl benchmark lab

> Reproduce Sonjoo large crawl benchmarks, inspect memory and recovery results, and interpret workload limits.

Canonical documentation: <https://sajaddehshiri.ir/sonjoo-seo-audit/contribute/crawl-benchmark/>

Status: Implemented (P1; local performance and scalability)
Scope: Crawl collection, rule analysis, persistence, reporting and recovery
Maximum crawl budget: 10,000 page records per run (hard limit)
Related: [Independent Rule Validation](https://sajaddehshiri.ir/sonjoo-seo-audit/contribute/rule-validation/), [Roadmap](https://github.com/sajaddp/sonjoo-seo-audit/blob/main/docs/todo.md)

The specification describes the workload and measurement policy. The
developer commands below run the implemented lab. Reference measurements are
historical results tied to the named source revisions and fixture runs.

## 1. Objective

Build a reproducible, repository-local benchmark suite that measures the
capacity, correctness, resource consumption and stability of Sonjoo on
websites within a maximum crawl budget of 10,000 page records per run.
Establish evidence-based performance baselines and detect regressions
across releases.

Use deterministic synthetic websites served locally. The benchmark must
exercise Sonjoo's actual production crawler and audit pipeline, not a mock
crawler or an alternative implementation. No live websites, external SEO
tools, third-party APIs, credentials, cloud services or new production
dependencies are required. Reuse the existing Rust, Python and optional
Chromium test infrastructure.

Keep heavyweight benchmarks out of normal development test runs. Do not
claim superiority over other crawlers or performance on arbitrary public
websites based solely on these local workloads.

## 2. Current architecture and known limits

The current benchmark exercises these production and test components.

* `src/crawler.rs`: discovery, frontier, robots handling, retries, concurrency,
  cancellation, crawl records and resume snapshots.
* `src/engine.rs` and `src/engine/runtime.rs`: validated audit options,
  production page collection and analysis. Use
  `collect_pages_configured`, `analyze_contexts_configured` and
  `audit_configured` as appropriate.
* `src/crawl_store.rs`, `src/crawl_journal.rs` and `src/storage.rs`: crawl
  snapshots, journal-backed recovery and audit persistence. The recovery
  profile exercises a graceful stop and resume in separate processes.
* `src/main.rs`, `src/config.rs`, `src/server.rs`: CLI, configuration and
  dashboard/API contracts.
* `tests/network_support/mod.rs`, `tests/fixtures/sites.py`,
  `tests/fixtures/browser_sites.py`, `tests/browser_live.rs`,
  `tests/transport_crawler.rs`: existing local test infrastructure.
* `.github/workflows/checks.yml` and `.github/workflows/crawl-benchmark.yml`:
  the development smoke checks and opt-in benchmark workflow.

The maximum crawl budget is fixed at 10,000 page records per run.
Preserve the existing engine and configuration limit of 10,000, the
dashboard API limit of 1,000, the list-mode limit of 1,000 seed URLs, and
the engine concurrency limit of 20. Run the scale workload through the
normal engine/CLI path and dashboard workloads within the existing API
limit.

Enforce the 10,000-page ceiling in the scenario loader, fixture generator,
benchmark runner and CI profile selection. Preserve production CLI,
configuration and engine validation. Reject out-of-range workloads before
allocating fixtures, starting servers or launching the crawler. Test the
upper boundary and immediate out-of-range rejection. Do not introduce
alternative execution paths, limit overrides, compatibility aliases or
reserved profiles. Do not change production capacity limits or safety
checks as part of this milestone.

## 3. Deliverables and repository layout

```text
tests/
  crawl_benchmark.rs
  fixtures/
    crawl_benchmark/
      README.md
      generator.py
      scenarios.json
scripts/
  compare_crawl_benchmarks.py
docs/
  CRAWL_BENCHMARK.md
target/
  crawl-benchmark/
    <run-id>/
      results.json
      summary.md
      diagnostics/
```

Use this layout unless existing test conventions justify consolidation.
The Python generator and comparison utility must use the standard library
unless a clearly justified test-only dependency is approved. Share existing
fixture helpers where practical. Do not add fixture assets to the production
binary. Do not commit generated sites, large reports or raw benchmark logs.
Keep compact, versioned reference baselines under test fixtures only when
their methodology and machine profile are documented.

## 4. Deterministic website generator

Implement a loopback-only HTTP fixture server that serves pages on demand
from a versioned scenario and seed. The same seed, scenario version and
parameters must reproduce the same graph, content, expected statuses and
fault locations. Generate HTML on demand rather than pre-generating files
or holding a second copy of the entire site in fixture-server memory.
The total declared page-record budget must not exceed 10,000.

Use stable URL IDs and generate realistic site sections (home, category,
listing/pagination, article and product pages). Configure:

* Number of eligible pages, graph depth, fan-out, internal links per page,
  cross-links, duplicate discovery paths and cycles.
* Response body sizes and content variability, representative metadata,
  assets and structured data.
* Robots rules, sitemap discovery, redirects, query variations, canonical
  targets and deliberately excluded or orphaned pages.
* Deterministic HTTP 404/410, temporary 429/503, Retry-After, slow responses
  and malformed resources in explicitly named fault scenarios.
* Optional local JavaScript rendering, mobile variants and asset requests.

For each scenario, provide an independently derived oracle of expected
eligible/discovered URLs, terminal outcomes, link sources, canonical targets
and applicable seeded defects. Derive it from the generator's scenario
definition, not from Sonjoo's results. Keep the generator's oracle separate
from the crawler's discovery logic. Assert small known graphs by hand to
validate the generator and oracle themselves.

Bind to an ephemeral loopback port with an explicit readiness handshake,
bounded requests, deterministic cleanup and local assets only. Support the
necessary concurrency without unbounded thread creation or request logging.
Collect aggregate request counts and enough per-URL request history to
verify deduplication and recovery; bound storage overhead.

## 5. Workload matrix

### 5.1 HTML crawl tiers

| Maximum page records | Tier     | Intended use                                  |
| -------------------: | -------- | --------------------------------------------- |
|                  100 | Smoke    | Fast correctness and harness sanity check     |
|                1,000 | Baseline | First meaningful throughput/resource baseline |
|               10,000 | Scale    | Maximum engine/CLI crawl budget               |

The tier denotes the maximum number of page records admitted by the
production crawl budget, not the number of HTTP requests. Healthy
workloads must collect exactly the tier's number of unique eligible HTML
pages. Mixed workloads must allocate the budget across successful pages
and additional terminal URL records according to production accounting,
and declare the expected eligible HTML count separately. Redirect hops,
error responses, resource requests, excluded URLs and sitemap requests
must be reported separately. Construct the fixture and oracle to fit the
selected budget; do not treat a page-limit stop as a complete crawl.
The scale tier is the final and largest permitted tier.

### 5.2 Scenario profiles

| Profile              | Required behavior                                                                                             |
| -------------------- | ------------------------------------------------------------------------------------------------------------- |
| Healthy graph        | All eligible pages reachable; no unexpected failures                                                          |
| Discovery complexity | Deep/wide graphs, cycles, repeated links, sitemap-only discoveries, URL filtering and known orphan candidates |
| Mixed failures       | Predictable status codes, redirects, throttling, retries, blocked URLs and timeouts                           |
| Resource-heavy       | Larger HTML, link density, images, CSS and JavaScript; bounded memory and reporting behavior                  |
| Recovery             | Stop at a defined checkpoint and resume without losing completed work                                         |
| Rendered             | Local JS-created content/links, actual Chromium collection and measurable render outcomes                     |

Avoid an exhaustive cross-product of every scenario, size, concurrency and
mode. Require a healthy and a mixed/discovery workload at the 1,000- and
10,000-page tiers, plus the dedicated recovery workload within the same
10,000-page ceiling.
Version the scenario definitions and document exact parameters.

### 5.3 Separate measurement modes

* **Collection:** actual production HTTP crawl and context construction;
  include robots, sitemap and network work performed by that path.
* **Analysis:** rule execution and site-wide aggregation on a collected
  crawl; measure any additional network requests and report generation.
* **End-to-end audit:** actual production audit, including collection,
  analysis, persistence and selected export(s). A collection-only result
  is not an audit-performance claim.
* **Rendered crawl/audit:** real Chromium, with rendering enabled and
  failures reported. Use exactly the 100- and 1,000-page rendered tiers.
* **Recovery:** checkpoint, stop, reopen, resume and final correctness check.

For full audit mode, use all default built-in rules where applicable.
Explicitly label any reduced-rule profile and report its enabled categories,
rule IDs/count and measured/unmeasured outcomes. Never compare a full audit
to a reduced-rule run as if the work were equivalent.

## 6. Measurement protocol

Build with `--release --locked`. Compile once, outside the timed region.
Run each measured configuration in a fresh Sonjoo child process with an
isolated temporary working directory and `SONJOO_HOME`. Start the fixture
server and verify readiness before timing; stop and clean up all processes
on success, failure or timeout. Measure the fixture server separately from
Sonjoo. Include Chromium descendants in the rendered resource accounting.

Where phase-level timing requires in-process instrumentation, use the
existing production engine entry points in an isolated benchmark worker and
identify the entry path in the report. Do not time test setup, fixture
generation, compilation or result comparison as crawl performance.
Separately record collection, analysis/aggregation, storage/export and
end-to-end elapsed times; do not derive end-to-end figures by adding
unrelated measurements or double-count overlapping work.

Use two clearly labeled crawl policy profiles:

* **Local throughput:** zero artificial crawl delay where the production
  configuration permits it, fixture-only scope, explicit bounded
  concurrency/per-host limits and robots enforcement.
* **Production-default policy:** effective normal configuration, including
  politeness delays, concurrency caps and retry behavior.

Only use zero delays for the isolated fixture. Never change production
defaults, bypass robots/SSRF protections or remove safeguards to improve a
benchmark number. Ensure all HTTP and browser traffic stays inside the
fixture environment. Explicitly disable unrelated remote integrations and
record any local rule probes performed.

Sweep supported concurrency values (e.g. 1, 3, 10, 20) on the 1,000-page
baseline; report effective per-host concurrency and delay. Choose and pin
a representative configuration for the 10,000-page scale tier. Use a warm-up run
followed by at least three measured runs for a published baseline; smoke
runs may use one measurement. Report median, minimum, maximum and
individual runs. Report per-request p95 latency only when sufficient
observations exist; do not call the p95 of three run times a reliable
tail-latency estimate.

Separate fresh-cache runs from explicitly warm-cache runs. Control Sonjoo
storage/cache state, browser lifecycle, seed, fixture version, configuration,
machine and workload. Do not describe a fresh application cache as a
guaranteed cold OS cache. Record CPU, logical cores, RAM, OS/architecture,
Rust/toolchain, build profile, Sonjoo commit, Chromium version, fixture
version, effective config, scenario seed and runner resource limits.

Calibrate fixture-server capacity with the same response mix and target
concurrency, record its CPU/latency/throughput and identify saturation.
Treat a generator-limited result as inconclusive for crawler throughput,
rather than as a measured Sonjoo capacity limit. Do not subtract fixture
latency from real elapsed time.

Use explicit wall-clock, memory and disk budgets for every tier. Define
budgets in the scenario/runner configuration before executing it; abort
safely on breach and report the exact reason and partial coverage. Reject runs that fail the selected tier's resource preflight.

## 7. Metrics and correctness gates

For each run report:

| Metric             | Definition                                                                                                            |
| ------------------ | --------------------------------------------------------------------------------------------------------------------- |
| Unique pages/sec   | Successfully collected unique eligible HTML pages divided by measured collection wall time                            |
| Requests/sec       | HTTP requests divided by the corresponding measured interval; includes retries/resources when relevant                |
| Elapsed time       | Collection, analysis, persistence/export and total wall time, with explicit measurement scope                         |
| Peak memory        | Peak RSS of the Sonjoo process tree under a documented sampling/accounting method; report units and sampling interval |
| CPU                | User/system CPU time and average utilization with a documented core normalization                                     |
| Storage            | Peak/final isolated workspace size and persisted snapshot/report size                                                 |
| Discovery coverage | Expected eligible URL set recovered divided by independently expected eligible URL set                                |
| Errors and retries | Expected and unexpected terminal failures, retry counts, render failures, missing records, and timeout reasons        |
| Recovery           | Checkpoint cost, resume time, retained completed records, duplicate completed-page fetches and final coverage         |

Use a platform-appropriate, tested resource sampler. On Linux, process
accounting may use `/proc` and available OS timing facilities; clearly
document the actual collection method. For other platforms, provide a
verified equivalent or report unsupported metrics as unavailable. Do not
pretend that parent RSS is total browser memory, summing per-process peaks
is a simultaneous process-tree peak, or sampled RSS is an exact peak.
Record fixture/benchmark-driver resources separately. Required baseline
metrics must be available on the reference benchmark platform.

Compare the actual URL and terminal-outcome sets with the fixture oracle.
Assert exact coverage for complete scenarios, no unexpected
missing or duplicate final records, correct exclusion/robots decisions,
expected redirects/errors and correct broken-link sources. Distinguish
logical terminal page records from legitimate repeated network requests
(HEAD/GET, redirects, retries, render asset loads and rule probes).
Record request duplication by method, purpose and URL where needed.

Verify representative known technical findings and their evidence during
end-to-end runs. Reuse the independent rule-validation contracts rather than
reimplementing all 398 rule tests here. Check that persisted crawl records
and exported results remain readable and reflect the same completed scope.

An exit code of zero is not sufficient. A run may be:

* `passed`: all required correctness assertions, completion criteria and
  resource budgets pass; required measurements are present.
* `failed`: a known correctness mismatch, crash, timeout, exceeded budget,
  unexpected partial result or required measurement failure.
* `blocked`: a known product limit, missing required capability or
  unsupported platform prevents execution.
* `inconclusive`: a fixture bottleneck, noisy environment or invalid
  measurement prevents a reliable performance comparison.

Report all outcomes, including incomplete or failed attempts. Never present
only successful runs or silently exclude slow runs from a baseline.

## 8. Recovery and persistence benchmark

Exercise the graceful snapshot and resume mechanism through the production
path using a 10,000-page healthy fixture. Start a deterministic
crawl, stop after a defined number of completed URLs (or a documented
deadline), persist its state, terminate the process, and reopen/resume in
a fresh process with the same scope and effective settings.

Use a stable fixture origin across both phases. Verify that completed
records and pending frontier entries survive, final URL/status/link
inventory matches an uninterrupted control run, and completed page
collection is not unnecessarily repeated. Allow explicitly documented
in-flight retry/recovery behavior and independent rule/asset probes.
Validate that incomplete runs are not reported as fully crawled.

This milestone measures graceful recovery and persisted snapshots. The
separate disk-backed-frontier task in [todo.md](https://github.com/sajaddp/sonjoo-seo-audit/blob/main/docs/todo.md) owns crash recovery
and durability testing within the same 10,000-page ceiling. Do not expand
that task's scope or report graceful recovery as crash recovery. Never fake
persistence by retaining the prior in-memory process state.

## 9. Developer commands and artifacts

Run these commands from the repository root. The heavier workloads use an
ignored Rust integration test and an explicit profile selected by a test-only
environment variable.

```sh
# Fast 100-page Rust smoke test and page-budget checks
cargo test --locked --test crawl_benchmark

# Also exercise the benchmark fixture, oracle and worker harness
SONJOO_BENCH_FIXTURE_SMOKE=1 \
  cargo test --locked --test crawl_benchmark smoke -- --exact

# Release-mode 1,000-page baseline (HTML)
SONJOO_BENCH_PROFILE=baseline \
  cargo test --release --locked --test crawl_benchmark -- \
  --ignored --nocapture --test-threads=1

# Maximum 10,000-page scale tier
SONJOO_BENCH_PROFILE=scale \
  cargo test --release --locked --test crawl_benchmark -- \
  --ignored --nocapture --test-threads=1

# Rendered workload
SONJOO_CHROMIUM=/path/to/chromium SONJOO_BENCH_PROFILE=rendered \
  cargo test --release --locked --test crawl_benchmark -- \
  --ignored --nocapture --test-threads=1

# Graceful recovery workload (10,000-page budget)
SONJOO_BENCH_PROFILE=recovery \
  cargo test --release --locked --test crawl_benchmark -- \
  --ignored --nocapture --test-threads=1

# Compare matching versioned benchmark runs
python3 scripts/compare_crawl_benchmarks.py \
  --baseline path/to/baseline/results.json \
  --candidate path/to/candidate/results.json
```

Define the profile-to-scenario mapping explicitly. The ignored target must
accept exactly `baseline`, `scale`, `rendered` and `recovery`; require an
explicit profile and reject any unknown profile. The normal smoke test
uses a 100-page Rust fixture. The benchmark fixture smoke, release profiles
and comparison tool use Python 3 and its standard library. The standard
Cargo test command and installed Sonjoo binary work without Python.
Apply the 10,000-page hard limit to all profiles.
Allow an optional `SONJOO_BENCH_OUTPUT` directory, defaulting to a unique
run directory under `target/crawl-benchmark/`.

Write versioned machine-readable JSON plus a concise Markdown summary.
Include the full measurement context, per-run raw metrics, correctness
checks, repeated-run statistics, status, missing capability or failure
reason, and relative diagnostics paths. Write results even when a measured
run fails; use atomic publication and no private audit data.

## 10. Baselines and regression policy

Establish the first measured baseline on a documented reference machine.
Do not invent a universal pages/sec or RAM target before measurement.
Once the baseline exists, approve per-profile performance/resource budgets
and regression tolerances. Store the baseline's commit, fixture version,
configuration and environment fingerprint with its metrics.

The comparison utility must refuse or flag incomparable runs (different
scenario, seed, size, mode, policy, build, environment or selected rules).
Show absolute and relative changes in median throughput, elapsed time,
peak memory, CPU, storage and correctness. Keep baseline and candidate runs
independent; do not overwrite historical results or automatically accept
regressions.

For comparable controlled environments, fail the performance gate when
an approved threshold is exceeded consistently under the defined repeated-run
protocol. Correctness regressions must always fail. Investigate noisy or
fixture-limited measurements before declaring a performance regression.
Changing a budget or baseline requires an explicit documented rationale;
do not weaken tests to make a build pass.

## 11. CI and release integration

Keep existing format, Clippy, unit, integration and Chromium checks. Run
the small Rust crawl in the normal test suite and set
`SONJOO_BENCH_FIXTURE_SMOKE=1` in CI to also exercise the lightweight
benchmark generator and oracle. Keep heavyweight benchmark tests explicitly
ignored by default.

Provide a separate opt-in GitHub Actions benchmark workflow with selectable
profiles, bounded timeouts, isolated storage and uploaded JSON/Markdown
artifacts even on failure. Expose exactly the four named profiles and
apply resource preflight checks before each run. Enforce the fixed page
budget for each profile.
Use a stable dedicated runner for enforceable performance comparisons;
shared hosted runners can provide informative measurements, not an
unqualified wall-time regression gate. Do not add paid services or require
third-party credentials.

A release performance summary must disclose the measured results for the
required workloads and identify failed, blocked or inconclusive runs.
Report the actual successfully completed page count and measured scope
for each mode. The maximum advertised benchmark scope is 10,000 page
records.

## 12. Implementation milestones and acceptance

1. **Inventory and fixture pilot:** verify current limits; implement the
   deterministic generator, independent oracle and small smoke suite.
   Deliberately inject a wrong expectation to verify that the harness
   fails, and verify safe cleanup on failure.
2. **Measurement harness:** run the production pipeline in isolated
   release-mode workers; implement phase timing, process-tree resource
   measurement, preflight limits and versioned result artifacts. Establish
   the 1,000-page baseline.
3. **Scale validation:** execute 1,000- and 10,000-page HTML
   healthy/mixed workloads, full audits and rendered baselines. Investigate
   bottlenecks and correctness issues; fix confirmed defects in scoped
   changes with regression tests. Document any failed or blocked workload.
4. **Recovery and boundary validation:** execute the 10,000-page graceful
   recovery workload and verify persisted state, final coverage and request
   accounting. Verify that out-of-range budgets are rejected before
   execution at every benchmark entry point. Preserve failed attempts
   and fix confirmed defects without bypassing safety or page-limit checks.
5. **Regression infrastructure:** implement comparable-run analysis, approve
   budgets from actual measurements, add the optional benchmark workflow
   and document repeatable commands. Independently review the oracle,
   resource accounting, run completeness and conclusions.

The P1 benchmark-infrastructure milestone is complete only when the
harness, oracle, smoke suite, result schema, comparison tooling and CI
integration are implemented; the required 1,000- and 10,000-page HTML,
100- and 1,000-page rendered, and 10,000-page graceful recovery workloads
have successful reproducible measurements; all out-of-range and unknown
profile rejection tests pass; and existing checks remain green. Document
measured results before updating the roadmap checkbox or publishing
performance claims. Do not add any benchmark workload outside the fixed
10,000-page limit.

## Implementation notes

The ignored Rust integration target is both the entry point and the isolated
worker for timed engine phases. The Python driver creates an ephemeral
loopback fixture, calibrates it, starts a fresh worker and validates the
result against the fixture oracle. It samples worker and fixture resources
separately. The end-to-end mode invokes the release `sonjoo audit` binary
with `crawler.max_pages` in its isolated configuration, `--save` and JSON
export, and checks both outputs. The existing CLI flag accepts up to 1,000
pages, and the supported configuration accepts up to 10,000. The store uses
gzip when an audit measures more than 1,000 pages or its report exceeds 8 MiB
as plain JSON. It retains queryable crawl metadata separately. Compression
kept the benchmark's 10,000-page report within SQLite's value limit. The audit
workloads leave the default SEO rule selection active and disable unrelated
external link checks. Any rule that cannot measure this local HTTP fixture
is reported in explicit rule coverage.

| Profile    | Workloads                                                                                                                                                           |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `baseline` | 100 records with normal politeness delays. 1,000-record healthy concurrency sweep at 1, 3, 10 and 20, mixed phases, resource-heavy collection and a full CLI audit. |
| `scale`    | 10,000-record healthy phases, mixed collection and a full CLI audit.                                                                                                |
| `rendered` | 100 and 1,000 records using Chromium to collect the actual DOM and local assets, followed by default-rule analysis and export.                                      |
| `recovery` | 10,000 records with a graceful stop after 500 completions, resume from the journal in a new process, and an uninterrupted control crawl.                            |

The fixture keeps standard HTML navigation and adds marked JavaScript-created
links in rendered mode. The scope stays equivalent across collection modes.
Sitemap-only pages are checked against the sitemap inventory. The current
linked crawler does not enqueue sitemap entries by interpreting that
inventory as extra crawl seeds. The mixed profile expects exactly four
fewer unique eligible HTML pages than terminal records.

RSS is sampled for the process group every 200 ms. It includes Chromium
processes that remain in the worker group and can miss peaks between samples.
The raw output separates simultaneous sampled RSS and the child high-water
mark from `wait4`. The reported peak is the larger lower-bound observation.
CPU times are from `wait4` for the worker and descendants reaped by it.
Utilization is normalized to one core, where 100% is one fully busy core.
The disk measure tracks the isolated worker directory. These measurements
exclude compilation and startup of the fixture. Scope-specific elapsed
phases and end-to-end CLI wall time are separate. The fixture latency p95
uses individual calibration requests. The capacity check considers both
request rate and fixture CPU consumption, so the injected timeout alone
does not count as fixture saturation. Each measurement starts with a fresh application state,
while OS caches remain under normal operating-system behavior.

The comparator refuses mismatched environment, fixture, policy, mode,
rule coverage or scope, and always fails a correctness mismatch. Supply an
optional JSON `--thresholds` file mapping metric name to approved relative
tolerance, for example `{"collectionSeconds": 0.20}`. A performance gate
fails only if every candidate sample exceeds the tolerance past the worst
reference sample. Use this only for repeated runs on a controlled matching
machine. The GitHub Actions workflow produces informational measurements.

Use repeatable `--case` options to compare specific compatible workloads in
a reference set that also preserves fixture-limited measurements.

## Apple M4 reference measurements

Reference host, Apple M4 with 10 logical cores and 16 GiB RAM, Darwin
27.2.0 on arm64. Rust 1.100.0 built the production binary and integration
worker with `--release --locked`. The compact files under
[`tests/fixtures/crawl_benchmark/baselines/`](https://github.com/sajaddp/sonjoo-seo-audit/tree/main/tests/fixtures/crawl_benchmark/baselines)
keep raw samples, warm-ups, phase timings, resource measurements and
correctness evidence. Each workload includes the checked-out Git commit
and a digest of the measured implementation. The 2026-11-28 refresh
measured the source later committed as `d844c2eb1c8426e5287dec984c5831227faccb66`.
Fixture version 1 and seed 719777 identify the generated site. Every row
below uses the median of three fresh worker runs after a warm-up.

| Workload                       | Terminal records | Eligible HTML | Median result                                 | Median peak RSS |
| ------------------------------ | ---------------: | ------------: | --------------------------------------------- | --------------: |
| Normal crawl policy, healthy   |              100 |           100 | 20.02 s collection                            |          17 MiB |
| Healthy crawl and analysis     |            1,000 |         1,000 | 0.28 s collection, 11.65 s analysis           |         896 MiB |
| Mixed crawl and analysis       |            1,000 |           996 | 1.22 s collection, 15.29 s analysis           |         907 MiB |
| CLI audit with SQLite and JSON |            1,000 |         1,000 | 18.49 s end to end                            |        1.17 GiB |
| Chromium crawl and analysis    |              100 |           100 | 30.57 s collection, 1.22 s analysis           |        1.86 GiB |
| Chromium crawl and analysis    |            1,000 |         1,000 | 299.14 s collection, 12.49 s analysis         |        1.87 GiB |
| Mixed crawl                    |           10,000 |         9,996 | 21.67 s collection                            |         446 MiB |
| Healthy crawl and analysis     |           10,000 |        10,000 | 21.75 s collection, 165.63 s analysis         |        5.37 GiB |
| CLI audit with SQLite and JSON |           10,000 |        10,000 | 307.14 s end to end                           |        8.35 GiB |
| Graceful recovery              |           10,000 |        10,000 | 22.36 s resume, zero completed-page refetches |         586 MiB |

The scale CLI samples retained about 1.73 GB of SQLite data and exported
about 1.69 GB of JSON per run. Every saved report and export agreed on
scope, rule coverage and the seeded missing-title finding.

The healthy 1,000-page crawl at concurrency 3 passed the correctness
checks. Its throughput result remains `inconclusive` because the workload
approached the CPU-saturated fixture's calibrated rate.

Compared with the previous Apple M4 reference, median peak RSS decreased by
41.0% for the 1,000-page analysis and 25.6% for the 10,000-page analysis.
The 10,000-page CLI audit's median peak RSS increased from 7.83 GiB to
8.35 GiB, with refreshed samples ranging from 7.07 GiB to 8.35 GiB. These
comparisons describe runs with different lockfiles.

Use a compatible workload for performance regression checks. The comparator
requires a matching lockfile, including when comparing against a reference
from the same machine.

```sh
python3 scripts/compare_crawl_benchmarks.py \
  --baseline tests/fixtures/crawl_benchmark/baselines/apple-m4-baseline.json \
  --candidate target/crawl-benchmark/<run-id>/results.json \
  --case 1000-healthy-phases-local-throughput-10
```

## Apple M4 before-and-after audit memory comparison

The comparison ran on 2026-11-28 with Apple M4 and Rust 1.100.1. Both
`d6d0dd9` (before) and `b94cda4` (after) were built with
`--release --locked` and the same lockfile. Each workload ran once per
revision on the `healthy` fixture (version 1, seed 719777) with all 398
default rules. Concurrency was 10 for 1,000 pages and 20 for 10,000,
with per-host concurrency of 5, zero crawl delays, and external link
checks disabled. The reference table above reports three-run medians.

| CLI workload                        |  Peak RSS before → after |   Wall time before → after |
| ----------------------------------- | -----------------------: | -------------------------: |
| 1,000 pages, SQLite and JSON        | 1,196 → 157 MiB (−86.9%) |    17.37 → 16.03 s (−7.7%) |
| 10,000 pages, SQLite and JSON       | 6.17 → 1.12 GiB (−81.8%) | 317.06 → 237.77 s (−25.0%) |
| 10,000 pages, JSON with `--no-save` | 6.25 → 1.14 GiB (−81.8%) |  215.43 → 209.63 s (−2.7%) |

The saved runs passed the benchmark's SQLite and JSON round-trip checks
with identical rule coverage across revisions. The `--no-save` runs
exported completed 10,000-page reports. The optimized CLI path uses
temporary disk space for per-category result rows.

The read-path comparison used the same saved 1,000-page audit for both
revisions. Each row measures a fresh process for that request workload.

| Read workload                          |   Peak RSS before → after | Request time before → after |
| -------------------------------------- | ------------------------: | --------------------------: |
| MCP, one rule-page request             |   874 → 10.6 MiB (−98.8%) |              443.7 → 0.6 ms |
| MCP, two concurrent rule-page requests | 1,738 → 10.9 MiB (−99.4%) |              829.9 → 0.7 ms |
| Dashboard JSON download                |  1,053 → 881 MiB (−16.4%) |       757 → 892 ms (+17.7%) |

Download time covers the request, response body delivery, and checksum
calculation. The download matched the previous report payload and headers,
with metadata object key order ignored. MCP response checks covered
filtering, pagination, and fallback for older reports without indexed rows.
