perf: optimize FTS and HNSW engines + real PostgreSQL benchmarks
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
FTS Engine (src/barabadb/fts/engine.nim): - Fix bm25Score doing O(n) linear scan per document - Cache IDF per token instead of recomputing for each doc - Use entry.termFreq directly instead of searching postings again - Result: FTS search +438% (249 -> 1360 queries/s) HNSW Vector Engine (src/barabadb/vector/engine.nim): - Optimize distance functions with float32 + 4x loop unrolling - Rewrite searchLayer: swap+pop instead of O(n) del, track worst-nearest instead of sorting nearest on every iteration - Result: HNSW insert +117% (245 -> 543 ops/s), search 2.2x faster Benchmarks: - Add real PostgreSQL comparison script (benchmarks/pg_bench.py) - Add report generator (benchmarks/generate_report.py) - Fix compare.nim cpuTime() bug (was dividing by 1M incorrectly) - Add nimble tasks: bench_pg, bench_report Docs: - Update README.md and docs/en/performance.md with real measured numbers - Add benchmarks/REAL_COMPARISON.md Version bump: 1.1.7 -> 1.1.8
This commit is contained in:
@@ -737,22 +737,39 @@ reg.register("greet", @[UDFParam(name: "name", typeName: "str")],
|
||||
## Performance Benchmarks
|
||||
|
||||
BaraDB is optimized for high throughput across all storage engines. Below are
|
||||
representative results on a modern desktop (AMD Ryzen 9, NVMe SSD):
|
||||
**real measured results** on AMD Ryzen 9 5900X, NVMe SSD:
|
||||
|
||||
### BaraDB Standalone
|
||||
|
||||
| Engine | Operation | Throughput | Latency |
|
||||
|--------|-----------|------------|---------|
|
||||
| **LSM-Tree** | Write 100K keys | ~580K ops/s | 1.7 µs/op |
|
||||
| **LSM-Tree** | Read 100K keys | ~720K ops/s | 1.4 µs/op |
|
||||
| **B-Tree** | Insert 100K keys | ~1.2M ops/s | 0.8 µs/op |
|
||||
| **B-Tree** | Point lookup 100K | ~1.5M ops/s | 0.6 µs/op |
|
||||
| **Vector (HNSW)** | Insert 10K vectors (dim=128) | ~45K ops/s | 22 µs/op |
|
||||
| **Vector (HNSW)** | Search top-10 | ~2ms/query | — |
|
||||
| **Vector (SIMD)** | Cosine distance (dim=768, n=10K) | ~850K ops/s | 1.2 µs/op |
|
||||
| **FTS** | Index 10K documents | ~320K docs/s | 3.1 µs/doc |
|
||||
| **FTS** | BM25 search (1K queries) | ~28K queries/s | 35 µs/query |
|
||||
| **Graph** | Add 1K nodes | ~2.5M nodes/s | 0.4 µs/node |
|
||||
| **Graph** | BFS traversal (100×) | ~12K traversals/s | 83 µs/traversal |
|
||||
| **Graph** | PageRank (1K nodes, 5K edges) | ~450 graphs/s | 2.2 ms/graph |
|
||||
| **LSM-Tree** | Write 100K keys | ~32.2K ops/s | 31.0 µs/op |
|
||||
| **LSM-Tree** | Read 100K keys | ~4.0M ops/s | 0.25 µs/op |
|
||||
| **B-Tree** | Insert 100K keys | ~2.5M ops/s | 0.40 µs/op |
|
||||
| **B-Tree** | Point lookup 100K | ~2.3M ops/s | 0.43 µs/op |
|
||||
| **Vector (HNSW)** | Insert 10K vectors (dim=128) | ~543 ops/s | 1.8 ms/op |
|
||||
| **Vector (HNSW)** | Search top-10 | ~2.6 ms/query | — |
|
||||
| **Vector (SIMD)** | Cosine distance (dim=768, n=10K) | ~1.17M ops/s | 0.85 µs/op |
|
||||
| **FTS** | Index 10K documents | ~120K docs/s | 8.3 µs/doc |
|
||||
| **FTS** | BM25 search (1K queries) | ~1.36K queries/s | 0.73 ms/query |
|
||||
| **Graph** | Add 1K nodes | ~931K nodes/s | 1.1 µs/node |
|
||||
| **Graph** | BFS traversal (100×) | ~5.6K traversals/s | 179 µs/traversal |
|
||||
| **Graph** | PageRank (1K nodes, 5K edges) | ~1.6K graphs/s | 6.1 ms/graph |
|
||||
|
||||
### BaraDB vs PostgreSQL (Real Comparison)
|
||||
|
||||
| Test | PostgreSQL | BaraDB | Speedup |
|
||||
|------|-----------|--------|---------|
|
||||
| KV Write (100K) | 16.82K/s | 33.24K/s | **2.0x** |
|
||||
| KV Read (100K) | 15.08K/s | 3.88M/s | **257.0x** |
|
||||
| BTree Insert (100K) | 17.66K/s | 2.50M/s | **141.6x** |
|
||||
| BTree Get (100K) | 14.50K/s | 2.64M/s | **182.3x** |
|
||||
| BTree Scan (1K ranges) | 2.39K/s | 7.97M/s | **3340.9x** |
|
||||
| FTS Index (10K docs) | 17.98K/s | 123.65K/s | **6.9x** |
|
||||
| FTS Search (1K queries) | 784.12/s | 1.34K/s | **1.7x** |
|
||||
|
||||
**Overall:** BaraDB is **6.8x faster** for in-process/embedded workloads.
|
||||
*(Note: PostgreSQL includes network round-trip overhead. BaraDB now outperforms PostgreSQL on all tested metrics including FTS after optimizations.)*
|
||||
|
||||
Run benchmarks yourself:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user