Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
668 lines (586 loc) · 29 KB
/
Copy pathMakefile
File metadata and controls
668 lines (586 loc) · 29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
# Makefile for vector-db-benchmark Rust implementation
#
# Targets:
# make setup - Install system deps and Rust toolchain
# make install - Build and install binary to PREFIX (/usr/local)
# make install-release - Download + verify a prebuilt release for this host
# make release-deb/rpm - Build the native .deb / .rpm on the target distro
# make vector-db-benchmark - Build the main CLI binary
# make test - Run Rust unit tests (no docker needed)
# make integration-test - Run integration tests (requires redis:8.6.0 docker)
# make benchmark - Run Rust microbenchmarks
# make check - Run linting (clippy) and formatting (rustfmt) checks
# make build - Build Rust code in release mode
# make docker-build - Build Docker image
# make docker-integration - Run benchmark in Docker against Redis
# make clean - Clean build artifacts
# Environment variables
ARCH := $(shell dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null || echo x86_64-linux-gnu)
export HDF5_DIR ?= /usr/lib/$(ARCH)/hdf5/serial
# Directories
DATASETS_DIR := datasets
# Docker
IMAGE_TAG ?= latest
# Default target
.PHONY: all
all: check build test
# ============================================================
# SETUP - Install system dependencies and Rust toolchain
# ============================================================
.PHONY: setup
setup:
@echo "=== Setting up development environment ==="
@OS=$$(uname -s); \
if [ "$$OS" = "Linux" ]; then \
echo "Detected Linux — installing libhdf5-dev and pkg-config via apt..."; \
sudo apt-get update && sudo apt-get install -y libhdf5-dev pkg-config; \
elif [ "$$OS" = "Darwin" ]; then \
echo "Detected macOS — installing hdf5 and pkg-config via brew..."; \
brew install hdf5 pkg-config; \
else \
echo "Unsupported OS: $$OS (expected Linux or Darwin)"; \
exit 1; \
fi
@if ! command -v cargo >/dev/null 2>&1; then \
echo "Rust not found — installing via rustup..."; \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
echo "NOTE: Run 'source $$HOME/.cargo/env' to add cargo to your current shell."; \
else \
echo "Rust already installed — running rustup update..."; \
rustup update; \
fi
@echo ""
@echo "=== Setup complete! Next step: make build ==="
# ============================================================
# BUILD
# ============================================================
.PHONY: build
build:
@echo "=== Building Rust code (release) ==="
cargo build --release
.PHONY: build-debug
build-debug:
@echo "=== Building Rust code (debug) ==="
cargo build
# Main CLI binary target
.PHONY: vector-db-benchmark
vector-db-benchmark:
@echo "=== Building vector-db-benchmark CLI ==="
cargo build --release --bin vector-db-benchmark
@echo ""
@echo "Binary built at: target/release/vector-db-benchmark"
@echo ""
@echo "Usage:"
@echo " ./target/release/vector-db-benchmark --help"
@echo " ./target/release/vector-db-benchmark --describe datasets"
@echo " ./target/release/vector-db-benchmark --engines 'redis-rs*' --datasets 'glove*' --skip-search"
# ============================================================
# INSTALL - Install binary to system path
# ============================================================
PREFIX ?= /usr/local
.PHONY: install
install: build
@echo "=== Installing vector-db-benchmark to $(PREFIX)/bin ==="
install -d $(PREFIX)/bin
install -m 755 target/release/vector-db-benchmark $(PREFIX)/bin/vector-db-benchmark
@echo "Installed: $(PREFIX)/bin/vector-db-benchmark"
# ============================================================
# PREBUILT RELEASE ARCHIVES (#366) — .github/workflows/release-binaries.yml
# runs these on every release and on PRs that touch the build.
# ============================================================
# Download the prebuilt archive for this host from a GitHub release, verify its
# checksum and extract it. TAG defaults to the latest release, DEST to
# ./vector-db-benchmark-<tag>.
.PHONY: install-release
install-release:
bash scripts/install-release.sh "$(TAG)" "$(DEST)"
# Build + package one target: dist/vector-db-benchmark-<TAG>-<platform>.tar.gz.
# Statically links HDF5/zlib/OpenSSL (--features release-static), needs cmake
# and a clean tree. RELEASE=1 also requires TAG to name the crate version.
RELEASE_TARGET ?= $(shell rustc -vV 2>/dev/null | sed -n 's/^host: //p')
RELEASE_OUT ?= dist
.PHONY: release-archive
release-archive:
@test -n "$(TAG)" || { echo "usage: make release-archive TAG=<tag> [RELEASE_TARGET=<triple>] [RELEASE=1]"; exit 2; }
bash scripts/release/package.sh --target "$(RELEASE_TARGET)" --tag "$(TAG)" --out "$(RELEASE_OUT)" $(if $(RELEASE),--release)
# Self-test of the release shell logic (tag/version policy, SHA256SUMS checks,
# unsafe-archive refusal, and publish.sh's refuse / resume / clobber decisions
# against a fake gh). No network, no cargo; runs in the PR check.
.PHONY: release-selftest
release-selftest:
bash scripts/release/selftest.sh
# Write, then re-check, SHA256SUMS over every archive in RELEASE_OUT.
.PHONY: release-checksums
release-checksums:
bash scripts/release/checksums.sh write "$(RELEASE_OUT)"
bash scripts/release/checksums.sh check "$(RELEASE_OUT)"
# Self-test of the package publish scripts (publish-apt.sh / publish-yum.sh)
# against fake aws / deb-s3 with tiny fixtures: codename grouping, dist tag ->
# directory, refuse / skip / overwrite, signing mandatory, RPMs before repodata.
# Needs rpm, rpmbuild, createrepo_c, dpkg-deb, gpg. No network.
.PHONY: release-selftest-packages
release-selftest-packages:
bash scripts/release/selftest-packages.sh
# Native .deb / .rpm packages (.github/workflows/release-packages.yml builds
# these inside a container of every codename / distro they are published for).
# Run ON the target distribution; DIST is the Debian/Ubuntu codename. Add
# INSTALL_DEPS=1 to apt-get/dnf the build dependencies and rustup first (what
# the CI containers do). Output: RELEASE_OUT/*.deb or *.rpm.
.PHONY: release-deb
release-deb:
@test -n "$(DIST)" || { echo "usage: make release-deb DIST=<codename> [INSTALL_DEPS=1] [TAG=<tag>]"; exit 2; }
bash scripts/release/build-deb.sh --dist "$(DIST)" --out "$(RELEASE_OUT)" $(if $(INSTALL_DEPS),--install-deps) $(if $(TAG),--release --tag "$(TAG)")
.PHONY: release-rpm
release-rpm:
bash scripts/release/build-rpm.sh --out "$(RELEASE_OUT)" $(if $(INSTALL_DEPS),--install-deps) $(if $(TAG),--release --tag "$(TAG)")
# Install a built package on this (bare) host and run it, from the file and
# from a local repository laid out like the production repository.
.PHONY: release-test-package
release-test-package:
@test -n "$(PKG)" || { echo "usage: make release-test-package PKG=<file.deb|file.rpm> [SHA=<40-hex>]"; exit 2; }
bash scripts/release/test-package.sh "$(PKG)" --expect-sha "$(or $(SHA),$(shell git rev-parse HEAD))"
# ============================================================
# TEST - Run Rust unit tests with dataset coverage
# ============================================================
.PHONY: test
test:
@echo "=== Running Rust unit tests ==="
cargo test --lib --release -- --nocapture
.PHONY: test-filter-only-debug
test-filter-only-debug:
cargo test --lib filter_only::
.PHONY: test-redis-numeric-range
test-redis-numeric-range:
cargo test --lib redis_numeric_range:: --release
cargo test --lib redis_numeric_range::
.PHONY: test-opensearch-maintenance
test-opensearch-maintenance:
cargo test --bin vector-db-benchmark merge_bounds_are_resolved_when_the_engine_is_constructed --release
cargo test --lib opensearch_maintenance:: --release
cargo test --lib opensearch_maintenance::
.PHONY: test-verbose
test-verbose:
@echo "=== Running Rust unit tests (verbose) ==="
cargo test --lib --release -- --nocapture --test-threads=1
# ============================================================
# INTEGRATION TEST - Requires redis:8.6.0 on port 6399
# ============================================================
.PHONY: integration-test
integration-test: integration-test-redis-cluster
@echo "=== Starting redis:8.6.0 for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d redis --wait
@echo "=== Running integration tests ==="
cargo test --test integration_redis --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping redis ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-pgvector
integration-test-pgvector:
@echo "=== Starting PgVector (pgvector/pgvector:pg16) for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d pgvector --wait
@echo "=== Running PgVector integration tests ==="
PGVECTOR_PORT=5433 cargo test --test integration_pgvector --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping PgVector ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-qdrant
integration-test-qdrant:
@echo "=== Starting Qdrant v1.13.4 for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d qdrant --wait
@echo "=== Running Qdrant integration tests ==="
QDRANT_GRPC_PORT=6335 cargo test --test integration_qdrant --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping Qdrant ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-elasticsearch
integration-test-elasticsearch:
@echo "=== Starting Elasticsearch 8.10.2 for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d elasticsearch --wait
@echo "=== Running Elasticsearch integration tests ==="
ELASTIC_PORT=9201 cargo test --test integration_elasticsearch --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping Elasticsearch ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-milvus
integration-test-milvus:
@echo "=== Starting Milvus 2.5.6 (+ etcd + minio) for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d milvus --wait
@echo "=== Running Milvus integration tests ==="
MILVUS_PORT=19531 cargo test --test integration_milvus --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping Milvus ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-weaviate
integration-test-weaviate:
@echo "=== Starting Weaviate 1.28.9 for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d weaviate --wait
@echo "=== Running Weaviate integration tests ==="
WEAVIATE_HTTP_PORT=8081 cargo test --test integration_weaviate --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping Weaviate ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-opensearch
integration-test-opensearch:
@echo "=== Starting OpenSearch 2.19.2 for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d opensearch --wait
@echo "=== Running OpenSearch integration tests ==="
OPENSEARCH_PORT=9202 cargo test --test integration_opensearch --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping OpenSearch ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-mongodb
integration-test-mongodb:
@echo "=== Starting MongoDB Atlas Local 8.0.4 for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d mongodb-search --wait
@echo "=== Running MongoDB integration tests ==="
MONGODB_PORT=27018 cargo test --test integration_mongodb --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping MongoDB ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-valkey
integration-test-valkey:
@echo "=== Starting Valkey Bundle for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d valkey --wait
@echo "=== Running Valkey integration tests ==="
VALKEY_PORT=6380 cargo test --test integration_valkey --release -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; \
echo "=== Stopping Valkey ===" ; \
docker compose -f tests/docker-compose.test.yml down ; \
exit $$EXIT_CODE
.PHONY: integration-test-dragonfly
integration-test-dragonfly:
@echo "=== Starting Dragonfly for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d dragonfly --wait
DRAGONFLY_PORT=6385 cargo test --test integration_dragonfly --release -- --test-threads=1; \
status=$$?; docker compose -f tests/docker-compose.test.yml down; exit $$status
.PHONY: integration-test-kividb
integration-test-kividb:
@echo "=== Starting KiviDB for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d kividb --wait
KIVIDB_PORT=6386 cargo test --test integration_kividb --release -- --test-threads=1; \
status=$$?; docker compose -f tests/docker-compose.test.yml down; exit $$status
.PHONY: integration-test-chroma
integration-test-chroma:
@echo "=== Starting Chroma for integration tests ==="
docker compose -f tests/docker-compose.test.yml up -d chroma --wait
CHROMA_PORT=8003 cargo test --test integration_chroma --release -- --test-threads=1; \
status=$$?; docker compose -f tests/docker-compose.test.yml down; exit $$status
# Vertex AI is cloud-only — there is no container to start, and the suite needs
# real GCP credentials. Listed so its absence from the Docker targets is a
# documented fact rather than an oversight.
.PHONY: integration-test-vertex
integration-test-vertex:
@echo "=== Vertex AI integration tests (cloud-only, needs GCP credentials) ==="
cargo test --test integration_vertex --release -- --test-threads=1
.PHONY: integration-test-no-docker
integration-test-no-docker:
@echo "=== Running integration tests (assumes redis on port 6399) ==="
cargo test --test integration_redis --release -- --nocapture --test-threads=1
# Run only against a dedicated Redis Search build with HNSW SQ8 support.
# REDIS_TEST_PORT selects the instance; the test claims it before any FLUSHALL.
.PHONY: integration-test-redis-sq8
integration-test-redis-sq8:
@test -n "$(REDIS_TEST_PORT)" || (echo "Set REDIS_TEST_PORT to a dedicated HNSW SQ8 Redis instance"; exit 1)
cargo test --test integration_redis --release test_binary_redis_hnsw_sq8_reaches_server -- --ignored --exact --nocapture --test-threads=1
# ============================================================
# BENCHMARK - Run Rust microbenchmarks
# ============================================================
.PHONY: benchmark
benchmark: build
@echo "=== Running Rust microbenchmarks ==="
@echo ""
@echo "--- HDF5 Benchmark (glove-25-angular: 1.18M × 25d) ---"
@if [ -f $(DATASETS_DIR)/glove-25-angular/glove-25-angular.hdf5 ]; then \
./target/release/bench_hdf5 $(DATASETS_DIR)/glove-25-angular/glove-25-angular.hdf5 3; \
else \
echo "Skipping: $(DATASETS_DIR)/glove-25-angular/glove-25-angular.hdf5 not found"; \
fi
@echo ""
@echo "--- NPY Benchmark (h-and-m: 105K × 2048d) ---"
@if [ -f $(DATASETS_DIR)/h-and-m-2048-angular/hnm/vectors.npy ]; then \
./target/release/bench_npy $(DATASETS_DIR)/h-and-m-2048-angular/hnm/vectors.npy 3; \
else \
echo "Skipping: h-and-m vectors.npy not found"; \
fi
@echo ""
@echo "--- JSONL Benchmark (random-100k: 100K × 100d) ---"
@if [ -f $(DATASETS_DIR)/random-100k/vectors.jsonl ]; then \
./target/release/bench_jsonl $(DATASETS_DIR)/random-100k/vectors.jsonl 3; \
else \
echo "Skipping: $(DATASETS_DIR)/random-100k/vectors.jsonl not found"; \
fi
# ============================================================
# CHECK - Linting and formatting
# ============================================================
.PHONY: check
check: fmt-check lint
.PHONY: lint
lint:
@echo "=== Running Clippy (Rust linter) ==="
cargo clippy
# ============================================================
# AGENT-CHECK — the whole no-Docker CI gate in one command
# ============================================================
#
# `make check` runs fmt + clippy and NO TESTS, which is the single most common
# way a change looks green locally and fails CI. This target reproduces exactly
# what CI's non-Docker jobs run, in the same order and the same profile:
#
# cargo fmt --check (ci.yml "Check formatting")
# cargo clippy --all-targets -- -D warnings (ci.yml "Run clippy")
# cargo test --lib --bins --release (ci.yml "Unit tests")
# cargo test --test {integration_cli,overhead_invariants,harness_invariants} --release
#
# --release is not incidental: CI runs the suites in release, so a
# `debug_assert!` does not exist there. Testing only in debug can pass a guard
# that is compiled out of the binary that ships.
#
# Docker-backed engine suites are NOT included — run `make integration-test-*`
# for those.
# `agent-check` is what CI RUNS, not a local imitation of it. `.github/workflows/ci.yml`
# invokes `agent-check-lint` and `agent-check-test` directly, and
# `harness_invariants.rs` fails if CI ever grows a raw `cargo` step again — so
# "this passes => CI passes" is enforced rather than asserted. A hand-copied
# duplicate of CI is precisely the thing that drifts and then lies.
#
# Split in two because CI runs them as separate parallel jobs; `agent-check`
# is the local convenience that runs both.
#
# --release is not incidental: CI runs the suites in release, so a
# `debug_assert!` does not exist there. Testing only in debug can pass a guard
# that is compiled out of the binary that ships.
#
# Docker-backed engine suites are NOT included — run `make integration-test-*`.
#
# Deliberately contains NO model call, even though this repo has ANTHROPIC_API_KEY
# wired up for the claude-pr-review / claude-issue-triage workflows. A gate has to
# be deterministic, free, and runnable offline; every failure this was built to
# catch (stale engine counts, missing make targets, renamed files, CI drift) is
# caught by the plain tests in harness_invariants.rs. Model review belongs in the
# advisory PR workflow, where a flaky or costly answer blocks nobody.
.PHONY: agent-check
agent-check: agent-check-lint agent-check-test
@echo ""
@echo "agent-check passed — this is the whole no-Docker CI gate."
.PHONY: agent-check-lint
agent-check-lint:
@echo "=== formatting ==="
cargo fmt --check
@echo "=== clippy (warnings are errors, as in CI) ==="
cargo clippy --all-targets -- -D warnings
.PHONY: agent-check-test
agent-check-test:
@echo "=== unit + binary tests (RELEASE, as in CI) ==="
cargo test --lib --bins --release
@echo "=== harness invariant suites (no container) ==="
cargo test --test integration_cli --release
cargo test --test overhead_invariants --release
cargo test --test harness_invariants --release
@echo "=== streaming peak-memory suite (#342, counting allocator, no container) ==="
cargo test --test streaming_memory --release
.PHONY: check-strict
check-strict: fmt-check lint-strict
.PHONY: lint-strict
lint-strict:
@echo "=== Running Clippy (strict mode - warnings as errors) ==="
cargo clippy -- -D warnings
.PHONY: fmt-check
fmt-check:
@echo "=== Checking Rust formatting ==="
cargo fmt --check
.PHONY: fmt
fmt:
@echo "=== Formatting Rust code ==="
cargo fmt
# ============================================================
# DATASETS - Prepare the MS MARCO v2.1 + Cohere embed-v3 corpus
# ============================================================
# Size is chosen by name, not by a flag: msmarco-cohere-1024-{100K,1M,10M}-cosine.
MSMARCO_DATASET ?= msmarco-cohere-1024-100K-cosine
MSMARCO_ARGS ?=
.PHONY: prepare-msmarco
prepare-msmarco:
@echo "=== Preparing $(MSMARCO_DATASET) (vectors + metadata) ==="
cargo run --release --bin prepare-msmarco -- --dataset $(MSMARCO_DATASET) $(MSMARCO_ARGS)
# ============================================================
# V0-CHECK - Compare Rust vs Python v0 precision/QPS/latency
# ============================================================
.PHONY: v0-check
v0-check: vector-db-benchmark
@echo "=== Running v0-check (Rust vs Python comparison) ==="
./scripts/v0_check.sh $(ENGINE) $(DATASET)
.PHONY: v0-check-all
v0-check-all: vector-db-benchmark
@echo "=== Running v0-check (all combinations) ==="
./scripts/v0_check.sh --all
# ============================================================
# DOCKER - Build image and run Docker-based integration tests
# ============================================================
.PHONY: docker-build
docker-build:
@echo "=== Building Docker image vector-db-benchmark:$(IMAGE_TAG) ==="
docker build -t vector-db-benchmark:$(IMAGE_TAG) .
.PHONY: docker-integration
docker-integration: docker-build
@echo "=== Running Docker integration test (h-and-m-2048-angular-filters + Redis) ==="
docker compose -f tests/docker-compose.docker-test.yml up -d redis --wait
@echo "=== Configuring Redis search-workers ==="
docker compose -f tests/docker-compose.docker-test.yml exec redis redis-cli CONFIG SET search-workers 8
@echo "=== Starting benchmark container ==="
docker compose -f tests/docker-compose.docker-test.yml run --rm benchmark; \
EXIT_CODE=$$?; \
echo "=== Stopping services ===" ; \
docker compose -f tests/docker-compose.docker-test.yml down ; \
exit $$EXIT_CODE
.PHONY: docker-integration-fast
docker-integration-fast: docker-build
@echo "=== Running fast Docker integration test (random-100 + Redis) ==="
docker compose -f tests/docker-compose.ci-test.yml up -d redis --wait
@echo "=== Configuring Redis search-workers ==="
docker compose -f tests/docker-compose.ci-test.yml exec redis redis-cli CONFIG SET search-workers 8
@echo "=== Starting benchmark container ==="
docker compose -f tests/docker-compose.ci-test.yml run --rm benchmark; \
EXIT_CODE=$$?; \
echo "=== Stopping services ===" ; \
docker compose -f tests/docker-compose.ci-test.yml down ; \
exit $$EXIT_CODE
# ============================================================
# CLEAN
# ============================================================
.PHONY: clean
clean:
@echo "=== Cleaning Rust build artifacts ==="
cargo clean
# ============================================================
# HELP
# ============================================================
.PHONY: help
help:
@echo "Available targets:"
@echo ""
@echo " Setup:"
@echo " make setup - Install system deps (libhdf5, pkg-config) and Rust toolchain"
@echo ""
@echo " Build & Test:"
@echo " make agent-check - THE no-Docker CI gate: fmt + clippy + tests (release)."
@echo " Use this, not 'make check' — 'check' runs NO tests."
@echo " make build - Build Rust code in release mode"
@echo " make install - Build and install binary to PREFIX (default: /usr/local)"
@echo " make install-release - Download a prebuilt release for this host [TAG=] [DEST=]"
@echo " make release-archive - Package a prebuilt release archive TAG=<tag> [RELEASE_TARGET=]"
@echo " make release-checksums - Write + check SHA256SUMS over RELEASE_OUT (default: dist)"
@echo " make release-selftest - Self-test the release scripts (publish logic vs a fake gh)"
@echo " make release-selftest-packages - Self-test publish-apt.sh / publish-yum.sh against fakes"
@echo " make release-deb - Build the .deb for this host's codename DIST=<codename> [INSTALL_DEPS=1]"
@echo " make release-rpm - Build the RPM on this el8/el9/el10/AL2023 host [INSTALL_DEPS=1]"
@echo " make release-test-package - Install + run a built package on this host PKG=<file>"
@echo " make test - Run Rust unit tests (no docker needed)"
@echo " make check - Linting + formatting ONLY (no tests; see agent-check)"
@echo " make check-strict - Run linting with warnings as errors"
@echo " make fmt - Auto-format Rust code"
@echo " make benchmark - Run Rust microbenchmarks (HDF5, NPY, JSONL)"
@echo ""
@echo " Integration Tests (each starts/stops Docker containers):"
@echo " make integration-test - Redis"
@echo " make integration-test-elasticsearch - Elasticsearch 8.10.2"
@echo " make integration-test-opensearch - OpenSearch 2.19.2"
@echo " make integration-test-pgvector - PgVector (PostgreSQL 16)"
@echo " make integration-test-qdrant - Qdrant v1.13.4"
@echo " make integration-test-weaviate - Weaviate 1.28.9"
@echo " make integration-test-milvus - Milvus 2.5.6"
@echo " make integration-test-mongodb - MongoDB Atlas Local 8.0.4"
@echo " make integration-test-valkey - Valkey Bundle (latest)"
@echo " make integration-test-dragonfly - Dragonfly"
@echo " make integration-test-kividb - KiviDB 1.1.2"
@echo " make integration-test-chroma - Chroma"
@echo " make integration-test-vertex - Vertex AI (cloud-only, needs GCP creds)"
@echo ""
@echo " Docker:"
@echo " make docker-build - Build Docker image (IMAGE_TAG=latest)"
@echo " make docker-integration - Run benchmark in Docker (h-and-m dataset)"
@echo " make docker-integration-fast - Run fast benchmark in Docker (random-100 dataset)"
@echo ""
@echo " Datasets:"
@echo " make prepare-msmarco - Download+build the MS MARCO v2.1 / Cohere embed-v3 corpus"
@echo " (vectors + real document metadata). Size is picked by name:"
@echo " MSMARCO_DATASET=msmarco-cohere-1024-{100K,1M,10M}-cosine"
@echo ""
@echo " Validation:"
@echo " make v0-check - Compare Rust vs Python v0 (precision, QPS, latency)"
@echo ""
@echo " make clean - Clean build artifacts"
@echo ""
@echo "Environment variables:"
@echo " HDF5_DIR - Path to HDF5 library (default: /usr/lib/<arch>/hdf5/serial)"
# Instrument the actual CLI used by the integration harness, as well as library
# and binary unit tests. Requires cargo-llvm-cov and rustup llvm-tools-preview.
# Keep coverage artifacts separate from normal builds and emit portable reports.
COVERAGE_DIR ?= $(CURDIR)/target/filter-only-coverage
.PHONY: coverage-filter-only
coverage-filter-only:
@set -eu; \
export CARGO_TARGET_DIR="$(COVERAGE_DIR)"; \
eval "$$(cargo llvm-cov show-env --sh)"; \
cargo llvm-cov clean --workspace; \
$(MAKE) agent-check-test; \
$(MAKE) integration-test; \
$(MAKE) integration-test-opensearch; \
mkdir -p "$(COVERAGE_DIR)/reports"; \
cargo llvm-cov report --release --json --output-path "$(COVERAGE_DIR)/reports/coverage.json"; \
cargo llvm-cov report --release --lcov --output-path "$(COVERAGE_DIR)/reports/lcov.info"
.PHONY: test-opensearch-query
test-opensearch-query:
cargo test --bin vector-db-benchmark engine::opensearch:: --release
cargo test --lib opensearch_query:: --release
cargo test --lib opensearch_query::
# Focused preparation guards in both profiles (also included in agent-check).
.PHONY: test-msmarco-preparation
test-msmarco-preparation:
cargo test --lib msmarco::preparation
cargo test --lib msmarco::preparation --release
cargo test --lib msmarco::derived
cargo test --lib msmarco::derived --release
# Focused compound correctness gates; AWS validation uses both build profiles.
.PHONY: test-compound test-compound-debug test-compound-release integration-test-compound
test-compound: test-compound-debug test-compound-release
test-compound-debug:
cargo test --lib compound
test-compound-release:
cargo test --lib --release compound
integration-test-compound:
docker compose -f tests/docker-compose.test.yml up -d redis opensearch --wait
OPENSEARCH_PORT=9202 cargo test --test integration_redis --test integration_opensearch --release compound_text_scalar -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; docker compose -f tests/docker-compose.test.yml down; exit $$EXIT_CODE
# Override COMPOUND_PROFILE= for the debug wiring check; release is CI's profile.
COMPOUND_PROFILE ?= --release
.PHONY: integration-test-compound-guards
integration-test-compound-guards:
docker compose -f tests/docker-compose.test.yml up -d redis opensearch --wait
OPENSEARCH_PORT=9202 cargo test --test integration_redis --test integration_opensearch $(COMPOUND_PROFILE) compound_text_scalar_wrong_count_is_fatal -- --nocapture --test-threads=1; \
EXIT_CODE=$$?; docker compose -f tests/docker-compose.test.yml down; exit $$EXIT_CODE
# Cluster-aware transport gates use a separate disposable three-primary cluster.
.PHONY: integration-test-redis-cluster
integration-test-redis-cluster:
bash tests/run-redis-cluster.sh
.PHONY: test-redis-cluster-guards
test-redis-cluster-guards:
cargo test --lib redis_transport:: --release
cargo test --lib redis_transport::
cargo test --lib config:: --release
cargo test --lib config::
# Focused lifecycle/reuse regression, including deliberate guard mutations.
TEXT_TAG_ENGINE ?= redis
.PHONY: integration-test-text-tag-profile
integration-test-text-tag-profile:
@case "$(TEXT_TAG_ENGINE)" in redis|opensearch) ;; *) echo 'TEXT_TAG_ENGINE must be redis or opensearch'; exit 2;; esac
docker compose -f tests/docker-compose.test.yml up -d $(TEXT_TAG_ENGINE) --wait
OPENSEARCH_PORT=9202 cargo test --test integration_$(TEXT_TAG_ENGINE) --release text_tag_ -- --nocapture --test-threads=1; \
status=$$?; docker compose -f tests/docker-compose.test.yml down; exit $$status