# MoonSearch benchmarks

M6c uses MoonBit's built-in benchmark harness. Fixtures are generated from
fixed rules, require no downloads, and exercise only public MoonSearch APIs.
They are performance measurements rather than correctness or CI timing gates.

Run the primary benchmark locally with an otherwise idle machine:

```bash
moon bench benchmarks \
  --release \
  --target native \
  --deny-warn \
  --frozen \
  --no-parallelize
```

The suite currently measures:

- `analysis/default_mixed_utf8`
- `analysis/en_stem_english`
- `analysis/chinese_dag`
- `index/segment_256_docs`
- `search/term_top10_2048_docs`
- `search/and_top10_2048_docs`
- `search/phrase_top10_2048_docs`
- `search/term_top10_100k_docs`
- `highlight/terms_mixed_utf8`
- `highlight/phrase_mixed_utf8`

Analyzer inputs and indexed documents contain deterministic English, Chinese,
and mixed UTF-8 text. Search and highlight fixtures build their immutable
2,048-document index before timing begins. The index benchmark intentionally
keeps construction inside the timed closure and reuses only the immutable
Schema, tokenizer registry, and source Documents.

Use this command to verify that benchmark code still compiles for every
supported backend without collecting noisy timing data:

```bash
moon bench benchmarks --build-only --target all --deny-warn --frozen
```

The normal CI workflow runs only that build-only check. The separate Benchmark
workflow is manually dispatched and uploads the native release console output,
MoonBit version, kernel details, and CPU information for 30 days.

Do not compare numbers from different targets, machines, power modes, or
toolchain versions as if they were equivalent. M6c deliberately defines no
absolute pass/fail thresholds and does not commit one developer machine's
results as a project baseline.

M8 also provides an isolated, opt-in million-document execution benchmark. It
uses an indexed-but-not-stored field to focus on dictionary/posting/scorer/Top-K
costs and is not part of the ordinary benchmark package:

```bash
moon bench benchmarks/scale \
  --release \
  --target native \
  --deny-warn \
  --frozen \
  --no-parallelize
```

The 1,000,000-document fixture is built before timing begins and can require
substantial memory. Run it only on an otherwise idle machine.
