-
Notifications
You must be signed in to change notification settings - Fork 261
test(benchmarks): vendor benchmark suite and add write-load harness #1021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
521bd91
chore(benchmarks): vendor basic-memory-benchmarks suite into benchmarks/
phernandez 69e5b7f
feat(benchmarks): add write-path load benchmark with per-ref venv har…
phernandez 16258dc
docs(benchmarks): record main vs PR-1002 write-load comparison
phernandez c075bca
docs(benchmarks): coalescing fix did not close the write-load gap
phernandez 4ee15d3
docs(benchmarks): materialization deferral validates the async-accept…
phernandez 472e4e1
feat(benchmarks): add postgres backend + high-concurrency scaling to …
phernandez d018eb1
docs(benchmarks): high-concurrency scaling + SQLite-vs-Postgres findings
phernandez 2c74ef5
docs(benchmarks): worker pool fixes the high-concurrency wall
phernandez 8cadadf
docs(benchmarks): Postgres pool + default-project seed fix the collapse
phernandez 3b117f7
docs(benchmarks): 3x variance bounds confirm the fixes are stable
phernandez 8e77219
docs(benchmarks): controlled 2x2 main (direct) vs branch (async)
phernandez 1ac8777
docs(benchmarks): split the 2x2 into readable per-metric rows
phernandez 790b7be
docs(benchmarks): flip 2x2 to C-rows with main/branch/speedup columns
phernandez 67ae6b1
docs(benchmarks): express the 2x2 improvement as percentages
phernandez 657fc13
feat(benchmarks): measure time_to_embedded (semantic vector-sync drain)
phernandez 0d3eb74
docs(benchmarks): time_to_embedded result — embedding keeps pace
phernandez bccda12
docs(benchmarks): scope embedding to local fastembed
phernandez 5cdee17
docs(benchmarks): SQLite PRAGMA sweep — no measurable gain
phernandez 48887f5
ci: add benchmarks scope to PR title checker
phernandez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| name: benchmark-nightly | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 8 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| nightly: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: astral-sh/setup-uv@v4 | ||
|
|
||
| - uses: extractions/setup-just@v2 | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --group dev --extra judge | ||
|
|
||
| - name: Fetch LoCoMo | ||
| run: just bench-fetch-locomo | ||
|
|
||
| - name: Convert LoCoMo | ||
| run: just bench-convert-locomo | ||
|
|
||
| - name: Run retrieval benchmark | ||
| run: | | ||
| uv run bm-bench run retrieval \ | ||
| --providers bm-local,bm-cloud,mem0-local \ | ||
| --dataset-id locomo \ | ||
| --dataset-path benchmarks/datasets/locomo/locomo10.json \ | ||
| --corpus-dir benchmarks/generated/locomo/docs \ | ||
| --queries-path benchmarks/generated/locomo/queries.json \ | ||
| --allow-provider-skip | ||
|
|
||
| - name: Run judge benchmark (best effort) | ||
| run: | | ||
| LATEST_RUN=$(ls -1t benchmarks/runs | head -n1) | ||
| uv run bm-bench run judge --run-dir "benchmarks/runs/${LATEST_RUN}" || true | ||
|
|
||
| - name: Upload benchmark artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: benchmark-nightly-artifacts | ||
| path: benchmarks/runs |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: benchmark-smoke | ||
|
|
||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| smoke: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: astral-sh/setup-uv@v4 | ||
|
|
||
| - uses: extractions/setup-just@v2 | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --group dev | ||
|
|
||
| - name: Run smoke benchmark | ||
| run: just bench-smoke | ||
|
|
||
| - name: Validate latest artifacts | ||
| run: | | ||
| LATEST_RUN=$(ls -1t benchmarks/runs | head -n1) | ||
| uv run bm-bench validate-artifacts --run-dir "benchmarks/runs/${LATEST_RUN}" | ||
|
|
||
| - name: Upload benchmark artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: benchmark-smoke-artifacts | ||
| path: benchmarks/runs | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| __pycache__/ | ||
| *.pyc | ||
| .venv/ | ||
| .pytest_cache/ | ||
| .ruff_cache/ | ||
| .idea/ | ||
|
|
||
| # Generated benchmark outputs | ||
| benchmarks/runs/ | ||
| benchmarks/results/public/ | ||
| benchmarks/generated/ | ||
| benchmarks/logs/ | ||
|
|
||
| # Downloaded datasets (source distribution may be restricted) | ||
| benchmarks/datasets/locomo/locomo10.json | ||
| benchmarks/datasets/locomo/locomo10.provenance.json | ||
| .env | ||
| benchmarks/bm-home/ | ||
| benchmarks/datasets/longmemeval/longmemeval_s.json | ||
| benchmarks/datasets/longmemeval/longmemeval_s.provenance.json | ||
| benchmarks/datasets/locomo-audit/ | ||
| benchmarks/.mem0-qdrant/ | ||
| benchmarks/datasets/convomem/ | ||
| benchmarks/.bm-homes/ | ||
| .supermemory/ | ||
| .venvs/ | ||
| .scratch/ |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.13 |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| # AGENTS.md - basic-memory-benchmarks Guide | ||
|
|
||
| ## Project Overview | ||
|
|
||
| `basic-memory-benchmarks` is a standalone benchmark harness for comparing Basic Memory against other memory systems. | ||
|
|
||
| Primary goals: | ||
| - Deterministic retrieval benchmarks | ||
| - Optional LLM-as-a-judge benchmarks | ||
| - Public, reproducible artifact publication (including provenance metadata) | ||
|
|
||
| This repo is intentionally isolated from `basic-memory` so benchmark dependencies do not pollute the product repo. | ||
|
|
||
| ## Build / Test Commands | ||
|
|
||
| - Install: `uv sync --group dev` | ||
| - Install judge extras: `uv sync --group dev --extra judge` | ||
| - Run tests: `uv run pytest -q` | ||
| - Lint: `uv run ruff check .` | ||
| - Type check: `uv run pyright` | ||
|
|
||
| Recommended local gate before pushing: | ||
| 1. `uv run pytest -q` | ||
| 2. `uv run ruff check .` | ||
| 3. `uv run pyright` | ||
|
|
||
| ## Benchmark Commands | ||
|
|
||
| CLI entrypoint: `uv run bm-bench ...` | ||
|
|
||
| Dataset and conversion: | ||
| - `uv run bm-bench datasets fetch --dataset locomo` | ||
| - `uv run bm-bench convert locomo --dataset-path benchmarks/datasets/locomo/locomo10.json --output-dir benchmarks/generated/locomo` | ||
|
|
||
| Run retrieval: | ||
| - `uv run bm-bench run retrieval --providers bm-local,mem0-local --dataset-id locomo --dataset-path benchmarks/datasets/locomo/locomo10.json --corpus-dir benchmarks/generated/locomo/docs --queries-path benchmarks/generated/locomo/queries.json --output-root benchmarks/runs --allow-provider-skip` | ||
|
|
||
| Run judge (optional): | ||
| - `uv run bm-bench run judge --run-dir benchmarks/runs/<run-id>` | ||
|
|
||
| Validate and publish: | ||
| - `uv run bm-bench validate-artifacts --run-dir benchmarks/runs/<run-id>` | ||
| - `uv run bm-bench publish --run-dir benchmarks/runs/<run-id> --destination benchmarks/results/public` | ||
|
|
||
| `just` shortcuts: | ||
| - `just bench-smoke` | ||
| - `just bench-fetch-locomo` | ||
| - `just bench-convert-locomo` | ||
| - `just bench-run-bm-local` | ||
| - `just bench-run-mem0-local` | ||
| - `just bench-run-full` | ||
| - `just bench-judge RUN_DIR=benchmarks/runs/<run-id>` | ||
| - `just bench-publish RUN_DIR=benchmarks/runs/<run-id>` | ||
|
|
||
| ## Repository Layout | ||
|
|
||
| - `src/basic_memory_benchmarks/cli.py` - CLI surface | ||
| - `src/basic_memory_benchmarks/runner.py` - run orchestration | ||
| - `src/basic_memory_benchmarks/providers/` - provider adapters (`bm-local`, `bm-cloud`, `mem0-local`, `zep-reference`) | ||
| - `src/basic_memory_benchmarks/scoring/` - retrieval + judge scoring | ||
| - `src/basic_memory_benchmarks/reporting/` - artifact writers / comparison helpers | ||
| - `src/basic_memory_benchmarks/converters/` - dataset conversion logic | ||
| - `src/basic_memory_benchmarks/datasets/` - dataset fetch/load helpers | ||
| - `benchmarks/datasets/` - source metadata + download helpers | ||
| - `benchmarks/generated/` - generated corpus/query outputs | ||
| - `benchmarks/runs/` - raw run artifacts | ||
| - `benchmarks/results/public/` - published bundles | ||
| - `tests/`, `test-int/` - unit and integration tests | ||
|
|
||
| ## Benchmark Integrity Rules | ||
|
|
||
| These are non-negotiable for headline comparisons: | ||
|
|
||
| 1. Use the same query set and same `top_k` across providers. | ||
| 2. Do not apply provider-specific query rewriting for headline runs. | ||
| 3. Keep official categories and adversarial breakout separate. | ||
| 4. Record provider `SKIPPED(reason)` explicitly; do not silently drop providers. | ||
| 5. Always capture provenance in `manifest.json`: | ||
| - benchmark repo SHA | ||
| - BM source + resolved BM SHA | ||
| - provider versions | ||
| - dataset source + checksum | ||
| - runtime metadata | ||
|
|
||
| ## Provider Notes | ||
|
|
||
| ### Basic Memory (`bm-local`) | ||
|
|
||
| - Interact via external `bm` CLI contract, not internal imports from `basic-memory`. | ||
| - Repeated runs against the same corpus path may reuse an existing BM project name. | ||
| - The benchmark command is typically invoked through `uv run ...` so `.venv/bin/bm` is used. | ||
|
|
||
| ### Mem0 (`mem0-local`) | ||
|
|
||
| - Requires `OPENAI_API_KEY` (or equivalent configured model creds). | ||
| - Ingest and search use a stable benchmark `user_id` namespace per run. | ||
| - Store source metadata (`source_doc_id`, `source_path`, `conversation_id`, `dataset_id`) for grounding. | ||
|
|
||
| ## Environment / Secrets | ||
|
|
||
| - Keep secrets in `.env` (already gitignored). | ||
| - Avoid exporting unrelated `BASIC_MEMORY_*` environment variables into benchmark runs unless intended. | ||
| - Prefer setting only required credentials for run reproducibility. | ||
|
|
||
| ## Dataset Policy | ||
|
|
||
| - If redistribution is allowed: publish snapshot + checksum. | ||
| - If restricted: publish canonical source link + downloader + checksum verification. | ||
| - Always publish conversion code and run artifacts. | ||
|
|
||
| ## Coding Guidelines | ||
|
|
||
| - Python 3.12+ style with type hints. | ||
| - Keep diffs focused and minimal. | ||
| - Fail fast; do not silently swallow benchmark-critical failures. | ||
| - Use `apply_patch` for targeted edits when practical. | ||
| - Add tests for behavior changes in adapters, scoring, or artifact schemas. | ||
|
|
||
| ## Git / Collaboration | ||
|
|
||
| - Use non-interactive git commands. | ||
| - Sign commits: `git commit -s`. | ||
| - Do not commit `.env`, generated runs, or local editor state. | ||
| - If changing benchmark behavior, include a brief note in PR/commit describing fairness or reproducibility impact. |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.