Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ concurrency:

env:
CARGO_TERM_COLOR: always
# The size of the shipped code, rounded up to 500 lines, and the number of tests, rounded up
# to 10. A change that crosses either number edits it here, in the same change, where its
# reader sees that the code grew or shrank. Neither ever passes 150,000 lines or 1,000 tests.
SHIPPED_LINES: 21000
TESTS: 380
TEST_LINES: 38000
# The shipped code, rounded up to 500 lines; the tests, rounded up to 10; the lines of tests,
# rounded up to 500. Each holds from both sides, at most the number and within one rounding of
# it, so a cleanup lowers it for good. Reaching one means a refactor first: a number is raised
# only when a planned stage of the work ends, never inside a fix (v2/AGENTS.md). Neither size
# ever passes 150,000 lines or 1,000 tests.
SHIPPED_LINES: 25000
TESTS: 400
TEST_LINES: 41000

jobs:
lint:
Expand Down Expand Up @@ -80,12 +82,13 @@ jobs:
test "$TESTS" -le 1000
test "$tests" -le "$TESTS"
test "$tests" -gt "$((TESTS - 10))"
- name: Test lines are at most the stated number
- name: Test lines are at most the stated number and within 500 of it
if: matrix.os == 'ubuntu-latest'
run: |
lines=$(find v2/*/tests v2/*/src -type f \( -path '*/tests/*' -o -name tests.rs \) -exec cat {} + | wc -l)
echo "$lines test lines; the stated number is $TEST_LINES"
test "$lines" -le "$TEST_LINES"
test "$lines" -gt "$((TEST_LINES - 500))"

minimum-rust:
runs-on: ubuntu-latest
Expand Down
6 changes: 4 additions & 2 deletions crates/contextdb-core/tests/timestamp_audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ fn walk_dir_into(dir: &Path, root: &Path, out: &mut Vec<String>) {
}

fn path_is_excluded(rel: &str) -> bool {
rel.split('/')
.any(|component| component == ".git" || component == ".worktrees")
rel.starts_with("v2/")
|| rel
.split('/')
.any(|component| component == ".git" || component == ".worktrees")
}

fn collapse_ws(line: &str) -> String {
Expand Down
88 changes: 67 additions & 21 deletions docs/performance/README.md

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions docs/performance/results/2026-11-14-declared-find.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Performance result: the consumer's declared find on a 16-core desktop-class machine, 2026-11-14

## Promise

- Promise, in the product's words: "As a store grows, a vector search stays within the time the product promises". No figure promised. The bars below were set for this step against the figures of 2026-11-12; they are not promises.
- Counted test that guards it: `a_filtered_search_reads_its_index_range_and_a_ranked_one_asks_every_vector` (`v2/contextdb/tests/vectors_statements.rs`) and `an_indexed_filter_reads_only_the_rows_it_returns` (`v2/contextdb/tests/counted_work.rs`) count the vectors compared and the rows read.

## Measurement

- Date: 2026-11-14; revision measured: `0c708a979e9eb5cbb1dca142f514edf96656711e`, five runs, the median of the five printed
- Program and command: the declared-find lines of `v2/numbers.sh` (`queries declared`): the consumer's own find statement, as it sends it, over a store built from its declarations
- Data: 100,008 passages, 13 indexes
- Passes and statistic: five passes after 5 untimed searches; p95 is the median over the five runs of the middle of a run's passes; threads: 1; memory limit: 1,073,741,824 bytes (read session)
- Machine: AMD Ryzen 9 9955HX, 16 cores and 32 threads, 59 GiB of memory (a 16-core desktop-class build machine; not a user's machine); operating system: unknown; Rust toolchain: unknown; user's machine: no
- Settings that can change the result: none recorded

## Figures

| Row | Figure | Unit | Previous figure and its date |
|---|---|---|---|
| one context, p95; rows read, median | 1.462; 37 | ms; rows | 1.489; 37 (2026-11-14, `090d140ec`); bar 1.50 |
| several contexts, p95; rows read, median | 3.913; 36 | ms; rows | 3.913; 36 (2026-11-14, `090d140ec`); bar 4.02 |
| all contexts, p95; rows read, median | 4.136; 36 | ms; rows | 4.167; 36 (2026-11-14, `090d140ec`); bar 4.33 |

## Limitations

- The bars were set by this step's measurement, not by the root documents, which promise no figure.
- Before the fixes of the last piece of SQL work, the same find read 12,004 rows on one context.
32 changes: 32 additions & 0 deletions docs/performance/results/2026-11-14-filtered-find.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Performance result: the filtered find on a 16-core desktop-class machine, 2026-11-14

## Promise

- Promise, in the product's words: "As a store grows, a vector search stays within the time the product promises". No figure promised for a search under a filter.
- Counted test that guards it: `a_filtered_search_reads_its_index_range_and_a_ranked_one_asks_every_vector` (`v2/contextdb/tests/vectors_statements.rs`) counts the vectors compared by a filtered search. The step's bars for the rows below were measured, not counted.

## Measurement

- Date: 2026-11-14; revision measured: `0c708a979e9eb5cbb1dca142f514edf96656711e` for the first row and the exact figure of the second (five runs, the median of the five printed); every other row keeps the figures of `cb9c072c687d1ab062ee90d9e4a460b2482cbab4` with measuring programs added, not taken again at the head
- Program and command: the filtered-find rows of the step's measurement (`passages`, `measure landed 5000000`)
- Data: 100,008 passages for the first two rows; a store of 5,000,000 rows for the others, with a filter passing the rows named and the key ranges named
- Passes and statistic: five passes for the passages, three for the others, each value as printed; threads: 1; memory limit: 1,073,741,824 bytes (read session); release build
- Machine: AMD Ryzen 9 9955HX, 16 cores and 32 threads, 59 GiB of memory (a 16-core desktop-class build machine; not a user's machine); operating system: unknown; Rust toolchain: unknown; user's machine: no
- Settings that can change the result: search mode as named in the rows

## Figures

| Row | Figure | Unit | Previous figure and its date |
|---|---|---|---|
| a filter passing 992 rows on a column with the advised index present, indexed, p95; rows read | 32.653; 2,558 rows read | ms | 32.961, 32.731, 33.000, 32.468, 32.693; 2,558 rows read (2026-11-14, `cb9c072c6`); 251 ms, 100,018 rows read before the last fixes |
| the same filter, exact, p95; rows read | 38.122; 2,561 rows read | ms | 38.3 to 39.5 (2026-11-14, `cb9c072c6`); the rest of this row (no index, 33.054, 32.892, 32.629, 32.620, 32.847) is not taken again |
| a filter passing 1,000 rows, rows compared one by one | 3.117, 3.062, 3.070 | ms | 2.98 (before the last fixes) |
| a filter passing 10,000 rows | 36.866, 36.774, 38.023 | ms | 37.4 to 39.9 |
| a filter passing 100,000 rows | 453.450, 442.631, 444.045, against the search 440.796, 442.036, 441.162 | ms | 618.6 |
| a key range of 39,000 rows of 5,000,000 (inside the one-by-one bound of 39,062), `small_set: yes` | 107.016, 112.535, 108.126; 39,010 rows read | ms | not measured |
| a key range of 39,200 rows (past the bound), `small_set: no` | 459.486, 459.392, 461.319; 1,455 rows read | ms | not measured |

## Limitations

- The step across the bound is 4.3 times in time (about 108 ms to 460 ms) at this size.
- Time figures are of this machine only; no timed figure is a promise.
33 changes: 33 additions & 0 deletions docs/performance/results/2026-11-14-find-100k.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Performance result: find at 100,008 vectors on a 16-core desktop-class machine, 2026-11-14

## Promise

- Promise, in the product's words: "As a store grows, a vector search stays within the time the product promises" (architectural views, the paragraph "A growing store keeps its search time"). No figure promised.
- Counted test that guards it: `an_indexed_search_does_fewer_distance_evaluations_than_exact` (`v2/contextdb/tests/vectors_index.rs`) counts the vectors compared on a small store. None yet at 100,000 vectors.

## Measurement

- Date: 2026-11-14; revision measured: `0c708a979e9eb5cbb1dca142f514edf96656711e`, five runs, the median of the five printed
- Program and command: the passages measurement of `v2/numbers.sh`, run with the build wrapper that gives it the machine alone; lines `passages_100008_find_*`
- Data: 100,008 real search passages, each a vector of 768 numbers and five other columns, in eight partitions, built and then sealed; the ten nearest asked for, over one partition, over several, over all
- Passes and statistic: five passes in each run, five runs; p95 is the median over the five runs of the middle of a run's passes; recall is the share of the recorded true ten nearest found, over 100 questions; threads: 1; memory limit: 1,073,741,824 bytes (read session)
- Machine: AMD Ryzen 9 9955HX, 16 cores and 32 threads, 59 GiB of memory (a 16-core desktop-class build machine; not a user's machine); operating system: unknown; Rust toolchain: unknown; user's machine: no
- Settings that can change the result: search mode as named in the figures; build rustflags none; popcount counting

## Figures

| Row | Figure | Unit | Previous figure and its date |
|---|---|---|---|
| one partition, exact, p95 | 1.411 | ms | 1.436, 2026-11-14 (`090d140ec`) |
| one partition, indexed, p95 and recall | 0.694 and 1.0000 (all ten on 100 of 100) | ms | 0.709 and 1.0000, 2026-11-14 (`090d140ec`) |
| one partition, automatic, p95 and recall | 1.411 and 1.0000 (100 of 100) | ms | 1.436 and 1.0000, 2026-11-14 (`090d140ec`) |
| several partitions, indexed, p95 and recall | 1.541 and 0.9990 (99 of 100) | ms | 1.570 and 0.9990, 2026-11-14 (`090d140ec`) |
| several partitions, automatic, p95 and recall | 3.800 and 1.0000 (100 of 100) | ms | 3.857 and 1.0000, 2026-11-14 (`090d140ec`) |
| all partitions, exact, p95 | 10.789 | ms | 10.856, 2026-11-14 (`090d140ec`) |
| all partitions, indexed, p95 and recall | 4.031 and 0.9990 (99 of 100) | ms | 4.063 and 0.9990, 2026-11-14 (`090d140ec`) |
| all partitions, automatic, p95 and recall | 4.027 and 0.9990 (99 of 100) | ms | 4.054 and 0.9990, 2026-11-14 (`090d140ec`) |

## Limitations

- Time figures are of this machine and build only; no timed figure is a promise.
- Recall is over 100 recorded questions.
31 changes: 31 additions & 0 deletions docs/performance/results/2026-11-14-find-1m.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Performance result: find at 1,000,000 vectors on a 16-core desktop-class machine, 2026-11-14

## Promise

- Promise, in the product's words: "As a store grows, a vector search stays within the time the product promises". No figure promised.
- Counted test that guards it: none yet at this size.

## Measurement

- Date: 2026-11-14; revision measured: `0c708a979e9eb5cbb1dca142f514edf96656711e` for the sightings rows (five runs, the median of the five); the generated-vector rows were not taken at this revision and keep the figures of `7f150eed3afb284c2c02220431c3cb858635f361`
- Program and command: the generated-vectors and sightings measurements of `v2/numbers.sh` (`measure synthetic` and `measure sightings`); lines `synthetic_1000000_*` and `sightings_1000000_*`
- Data: two stores of 1,000,000 generated vectors of 768 numbers in one partition each: random vectors near centres, and sightings in tracks of ten whose appearance drifts; sealed and grouped before searching; 100 questions
- Passes and statistic: p95 and p50 as the program prints them; threads: 1; memory limit: 1,073,741,824 bytes (read session)
- Machine: AMD Ryzen 9 9955HX, 16 cores and 32 threads, 59 GiB of memory (a 16-core desktop-class build machine; not a user's machine); operating system: unknown; Rust toolchain: unknown; user's machine: no
- Settings that can change the result: search mode as named in the figures; build rustflags none

## Figures

| Row | Figure | Unit | Previous figure and its date |
|---|---|---|---|
| generated, indexed, p95 and recall (not taken at the head; `7f150eed3`) | 1.132 and 1.0000 (100 of 100) | ms | 1.122 and 1.0000, 2026-11-12 |
| generated, automatic, p95 (same) | 1.054 | ms | 1.012, 2026-11-12 |
| generated, exact, p95 (same) | 176.581 | ms | 180.378, 2026-11-12 |
| sightings, indexed, p95 and recall | 30.577 and 1.0000 | ms | 30.011 and 1.0000, 2026-11-14 (`090d140ec`) |
| sightings, automatic, p95 and recall | 27.844 and 1.0000 | ms | 28.180 and 1.0000, 2026-11-14 (`090d140ec`) |
| load of 1,000,000 generated vectors (same) | 27.0 | s | 26.5 to 27.1, 2026-11-12 |

## Limitations

- Time figures are of this machine and build only; no timed figure is a promise.
- Recall is over 100 questions.
29 changes: 29 additions & 0 deletions docs/performance/results/2026-11-14-find-5m.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Performance result: find at 5,000,000 vectors on a 16-core desktop-class machine, 2026-11-14

## Promise

- Promise, in the product's words: "As a store grows, a vector search stays within the time the product promises". No figure promised.
- Counted test that guards it: none yet.

## Measurement

- Date: 2026-11-14; not taken again at revision `0c708a979` (a store of this size takes the better part of an hour to build); the figures below are of the fixed engine `cb9c072c687d1ab062ee90d9e4a460b2482cbab4` with measuring programs added (the final landing run of `numbers.sh` did not include this size)
- Program and command: `measure landed 5000000` on a built store of 5,000,000 sightings, reopened
- Data: 5,000,000 generated sightings of 768 numbers in one partition
- Passes and statistic: three passes, each value as printed; threads: 1; memory limit: 1,073,741,824 bytes (read session); release build
- Machine: AMD Ryzen 9 9955HX, 16 cores and 32 threads, 59 GiB of memory (a 16-core desktop-class build machine; not a user's machine); operating system: unknown; Rust toolchain: unknown; user's machine: no
- Settings that can change the result: search mode as named in the figures

## Figures

| Row | Figure | Unit | Previous figure and its date |
|---|---|---|---|
| indexed, three passes, recall | 115.926, 116.138, 114.075 and 1.0000 | ms | 126.9, 127.5, 126.6 (before the last fixes, 2026-11-14) |
| exact, three passes | 856.9, 874.4, 864.0 | ms | not recorded |
| indexed with a second sort key, three passes, recall | 119.851, 118.685, 118.939 and 1.0000 | ms | 129.3, 129.4, 128.9 (before the last fixes, 2026-11-14) |
| indexed with a rank policy, three passes, recall | 123.584, 116.221, 116.177 and 0.9900 | ms | 129.9, 126.9, 127.6 (before the last fixes, 2026-11-14) |

## Limitations

- The recall of the ranked search is against the plain exact search; recall against the ranked exact search is not measured at this size.
- Time figures are of this machine only; no timed figure is a promise.
31 changes: 31 additions & 0 deletions docs/performance/results/2026-11-14-import-rate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Performance result: import rate on a 16-core desktop-class machine, 2026-11-14

## Promise

- Promise, in the product's words: "A large import therefore runs only as fast as maintenance keeps up, and a search made in the middle of it stays fast". No figure promised.
- Counted test that guards it: none yet.

## Measurement

- Date: 2026-11-14; revision measured: `0c708a979e9eb5cbb1dca142f514edf96656711e` for the rows of the first group, which come from the 100,008-passage, 62,447-command and sightings programs of five runs (the median of the five printed); the rows marked "not taken again" keep the figures of `7f150eed3afb284c2c02220431c3cb858635f361`
- Program and command: the load lines of `v2/numbers.sh` (`million_rows_load`, `passages_100008_load`, `synthetic_1000000_*`, `anchors_62447_load`)
- Data: as named in each row; 500 rows to a commit
- Machine: AMD Ryzen 9 9955HX, 16 cores and 32 threads, 59 GiB of memory (a 16-core desktop-class build machine; not a user's machine); operating system: unknown; Rust toolchain: unknown; user's machine: no

## Figures

| Row | Figure | Unit | Previous figure and its date |
|---|---|---|---|
| 1,000,000 small rows loaded under a 64 MiB limit (not taken again) | 11.3 | s | 10.7, 2026-11-12 |
| 100,008 passages loaded | 3.5 | s | 3.5, 2026-11-14 (`090d140ec`) |
| 138,084 rows of 62,447 commands loaded | 12.6 | s | 12.7, 2026-11-14 (`090d140ec`) |
| 1,000,000 sightings loaded | 35.3 | s | 35.2, 2026-11-14 (`090d140ec`) |
| those sightings sealed, 245 cycles | 15.4 | s | 15.5, 2026-11-14 (`090d140ec`) |
| those sightings grouped, 1,123 cycles | 343.4 | s | 343.5, 2026-11-14 (`090d140ec`) |
| 1,000,000 generated vectors loaded (not taken again) | 27.0 | s | 26.5 to 27.1, 2026-11-12 |
| those vectors sealed, 245 cycles (not taken again) | 20.4 | s | 25.7, 2026-11-12 |
| those vectors grouped, 1,150 cycles (not taken again) | 348.6 | s | 365.8, 2026-11-12 |

## Limitations

- A search made during the import is not measured yet; no limit on the vectors a search compares one by one exists yet.
25 changes: 25 additions & 0 deletions docs/performance/results/2026-11-14-one-commit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Performance result: the cost of one commit on a 16-core desktop-class machine, 2026-11-14

## Promise

- Promise, in the product's words: "Rows, relationships, vectors and the index state built from them commit together or not at all". No figure promised for its speed.
- Counted test that guards it: `a_kill_at_any_storage_call_of_a_commit_leaves_all_or_nothing` and `a_kill_inside_a_commit_of_vectors_keeps_rows_and_vectors_together` (`v2/contextdb/tests/crash/main.rs`) stop the process at every storage call of a commit and check that all of it or none of it is there.

## Measurement

- Date: 2026-11-14; revision measured: `0c708a979e9eb5cbb1dca142f514edf96656711e`, five runs, the median of the five printed
- Program and command: the `readme_*` lines of `v2/numbers.sh` (`measure readme`)
- Data: 20,000 notes of 1.6 KB, one commit per row
- Machine: AMD Ryzen 9 9955HX, 16 cores and 32 threads, 59 GiB of memory (a 16-core desktop-class build machine; not a user's machine); operating system: unknown; Rust toolchain: unknown; user's machine: no

## Figures

| Row | Figure | Unit | Previous figure and its date |
|---|---|---|---|
| 20,000 commits of one row | 28.0 | s | 27.9, 2026-11-14 (`090d140ec`); 11.1, 2026-11-14 (`7f150eed3`, a run in another folder) |
| the store they leave | 2.0 | MiB | 2.0, 2026-11-14 (`090d140ec`) |

## Limitations

- The time is of this machine only; no timed figure is a promise.
- The merged code (`4495faf1a`) took 27.6 to 29.9 s in the same five runs, so the engine did not slow it; the earlier 11.1 s was taken by `numbers.sh` in another folder, and the cause of the difference was not looked for.
Loading
Loading