Skip to content
This repository was archived by the owner on Feb 18, 2026. It is now read-only.

Commit 2eb4cee

Browse files
committed
feat: add stress tests for performance benchmarking at scale
1 parent 9ed1c90 commit 2eb4cee

3 files changed

Lines changed: 752 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ temp/
4545
# Prettier cache
4646
.prettier-cache
4747

48-
# Test databases
48+
# Test databases (includes stress test artifacts)
4949
*.db
5050
*.db-shm
5151
*.db-wal

Makefile

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# sqlite-diskann Makefile
22
# Cross-platform SQLite extension for DiskANN vector search
33

4-
.PHONY: all clean test test-native test-all check asan valgrind bear lint clang-tidy fmt help
4+
.PHONY: all clean test test-native test-all test-stress check asan valgrind bear lint clang-tidy fmt help
55

66
# Compiler and flags
77
CC ?= gcc
@@ -22,10 +22,11 @@ BUILD_DIR = build
2222
# Output
2323
EXTENSION = diskann.so
2424
TEST_BIN = test_diskann
25+
STRESS_BIN = test_stress
2526

2627
# Source files
2728
SOURCES = $(SRC_DIR)/diskann_api.c $(SRC_DIR)/diskann_blob.c $(SRC_DIR)/diskann_insert.c $(SRC_DIR)/diskann_node.c $(SRC_DIR)/diskann_search.c
28-
TEST_C_SOURCES = $(filter-out %/test_runner.c, $(wildcard $(TEST_DIR)/c/test_*.c))
29+
TEST_C_SOURCES = $(filter-out %/test_runner.c %/test_stress.c, $(wildcard $(TEST_DIR)/c/test_*.c))
2930
TEST_RUNNER = $(TEST_DIR)/c/test_runner.c
3031
UNITY_SOURCES = $(TEST_DIR)/c/unity/unity.c
3132
SQLITE_SOURCE = vendor/sqlite/sqlite3.c
@@ -34,10 +35,14 @@ SQLITE_SOURCE = vendor/sqlite/sqlite3.c
3435
UNAME_S := $(shell uname -s)
3536
ifeq ($(UNAME_S),Darwin)
3637
EXTENSION = diskann.dylib
38+
# Allow undefined symbols (resolved at runtime when loaded into SQLite)
3739
LDFLAGS += -dynamiclib -undefined dynamic_lookup
3840
endif
3941
ifeq ($(UNAME_S),Linux)
4042
EXTENSION = diskann.so
43+
# Allow undefined symbols (resolved at runtime when loaded into SQLite)
44+
# Equivalent to macOS's -undefined dynamic_lookup
45+
LDFLAGS += -Wl,--allow-shlib-undefined
4146
endif
4247

4348
# Default target
@@ -70,6 +75,17 @@ test-all: test-native
7075
@command -v npm >/dev/null 2>&1 || { echo "Error: npm not installed" >&2; exit 1; }
7176
npm run test:ts
7277

78+
# Build and run stress tests (separate from regular tests due to long runtime)
79+
test-stress: $(BUILD_DIR)/$(STRESS_BIN)
80+
@echo "Running stress tests (this may take several minutes)..."
81+
$(BUILD_DIR)/$(STRESS_BIN)
82+
@echo "Cleaning up stress test database files..."
83+
@rm -f /tmp/diskann_stress_*.db*
84+
85+
$(BUILD_DIR)/$(STRESS_BIN): $(SOURCES) $(TEST_DIR)/c/test_stress.c $(UNITY_SOURCES) $(BUILD_DIR)/sqlite3.o | $(BUILD_DIR)
86+
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I$(SRC_DIR) -I$(TEST_DIR)/c -o $@ $^ $(LIBS)
87+
@echo "Built stress test suite: $@"
88+
7389
$(BUILD_DIR)/$(TEST_BIN): $(SOURCES) $(TEST_C_SOURCES) $(TEST_RUNNER) $(UNITY_SOURCES) $(BUILD_DIR)/sqlite3.o | $(BUILD_DIR)
7490
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -I$(SRC_DIR) -I$(TEST_DIR)/c -o $@ $^ $(LIBS)
7591
@echo "Built test suite: $@"
@@ -125,6 +141,7 @@ help:
125141
@echo " test Build and run native C tests (alias for test-native)"
126142
@echo " test-native Build and run native C tests only"
127143
@echo " test-all Build and run both native C and TypeScript tests"
144+
@echo " test-stress Build and run stress tests (300k/100k vectors, takes ~5-10min)"
128145
@echo " check Alias for test"
129146
@echo " asan Build and run with AddressSanitizer (fast memory checks)"
130147
@echo " valgrind Build and run with Valgrind (thorough memory checks)"

0 commit comments

Comments
 (0)