-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
229 lines (195 loc) · 7.07 KB
/
Copy pathMakefile
File metadata and controls
229 lines (195 loc) · 7.07 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
.PHONY: all build build-server build-benchmark run run-json run-debug \
bench bench-all bench-integration bench-unit benchmark benchmark-search benchmark-custom \
test test-coverage test-race test-recall test-recall-report \
fmt vet lint tidy clean install-tools help verify
# Build output directory
BUILD_DIR := bin
# Binary names
SERVER_BIN := $(BUILD_DIR)/vex-server
BENCHMARK_BIN := $(BUILD_DIR)/vex-benchmark
# Go commands
GOCMD := go
GOBUILD := $(GOCMD) build
GORUN := $(GOCMD) run
GOCLEAN := $(GOCMD) clean
GOTEST := $(GOCMD) test
GOFMT := $(GOCMD) fmt
GOVET := $(GOCMD) vet
GOMOD := $(GOCMD) mod
# Version info
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -ldflags "-X main.Version=$(VERSION)"
# Default target
all: tidy fmt ci build
# Build both server and benchmark
build: build-server build-benchmark
# Build server binary
build-server:
@echo "Building vex-server..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(SERVER_BIN) ./cmd/vex-server
# Build benchmark binary
build-benchmark:
@echo "Building vex-benchmark..."
@mkdir -p $(BUILD_DIR)
$(GOBUILD) $(LDFLAGS) -o $(BENCHMARK_BIN) ./cmd/vex-benchmark
# Run server directly
run:
@echo "Starting Vex server..."
$(GORUN) ./cmd/vex-server/main.go
# Run server with JSON logging
run-json:
@echo "Starting Vex server with JSON logging..."
$(GORUN) ./cmd/vex-server/main.go -log-format=json
# Run server with debug logging
run-debug:
@echo "Starting Vex server with debug logging..."
$(GORUN) ./cmd/vex-server/main.go -log-level=debug
# Run benchmark (insert mode)
benchmark:
@echo "Running insert benchmark..."
$(GORUN) ./cmd/vex-benchmark/main.go -mode=insert -concurrency=50 -n=100000
# Run benchmark (search mode)
benchmark-search:
@echo "Running search benchmark..."
$(GORUN) ./cmd/vex-benchmark/main.go -mode=search -concurrency=50 -n=50000
# Run all benchmarks (unit + integration)
bench: bench-unit bench-integration
# Run all unit benchmarks
bench-all: bench-unit
# Run unit benchmarks (micro-level performance tests)
bench-unit:
@echo "Running unit benchmarks..."
$(GOTEST) -run='^$$' -bench=. -benchmem -benchtime=3s ./benchmarks/...
# Run storage benchmarks specifically
bench-storage:
@echo "Running storage benchmarks..."
$(GOTEST) -run='^$$' -bench=. -benchmem -benchtime=3s ./benchmarks/storage/
# Integration benchmarks (requires running server)
bench-integration:
@echo "Running integration benchmarks..."
@echo "Note: Ensure vex-server is running on localhost:6379"
@echo ""
$(GORUN) ./cmd/vex-benchmark/main.go -mode=insert -concurrency=50 -n=100000
$(GORUN) ./cmd/vex-benchmark/main.go -mode=search -concurrency=50 -n=50000
# Run custom benchmark
benchmark-custom:
@echo "Running custom benchmark..."
@echo "Usage: make benchmark-custom ARGS='-mode=search -concurrency=100 -n=200000 -prepare-n=100000 -k=10'"
$(GORUN) ./cmd/vex-benchmark/main.go $(ARGS)
# Run tests
test:
@echo "Running tests..."
$(GOTEST) -v ./...
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Run tests with race detector
test-race:
@echo "Running tests with race detector..."
$(GOTEST) -v -race ./...
# Run HNSW recall@k accuracy tests
test-recall:
@echo "Running HNSW recall@k accuracy tests..."
$(GOTEST) -v -count=1 -run=TestHNSWRecallAccuracy ./benchmarks/storage/
# Run recall tests with detailed report
test-recall-report:
@echo "Generating HNSW recall accuracy report..."
$(GOTEST) -v -count=1 -run=TestHNSWRecallReport ./benchmarks/storage/
# Diagnose HNSW parameter impact on recall
test-recall-diagnosis:
@echo "Diagnosing HNSW parameter impact on recall..."
$(GOTEST) -v -count=1 -run=TestHNSWParameterDiagnosis ./benchmarks/storage/
# Test HNSW recall with clustered (realistic) data
test-recall-clustered:
@echo "Testing HNSW recall with clustered data..."
$(GOTEST) -v -count=1 -run=TestHNSWRecallWithClusteredData ./benchmarks/storage/
# Format code
fmt:
@echo "Formatting code..."
$(GOFMT) ./...
# Run go vet
vet:
@echo "Running go vet..."
$(GOVET) ./...
# Run golangci-lint
lint:
@echo "Running golangci-lint..."
golangci-lint run ./...
# Tidy dependencies
tidy:
@echo "Tidying dependencies..."
$(GOMOD) tidy
# Clean build artifacts
clean:
@echo "Cleaning..."
$(GOCLEAN)
rm -rf $(BUILD_DIR)
rm -f coverage.out coverage.html
# Install development tools
install-tools:
@echo "Installing development tools..."
$(GOCMD) install golang.org/x/tools/cmd/goimports@latest
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Help
help:
@echo "Vex Makefile"
@echo ""
@echo "Available targets:"
@echo ""
@echo "Building:"
@echo " all - Format, tidy, and build everything (default)"
@echo " build - Build vex-server and vex-benchmark binaries"
@echo " build-server - Build only the vex-server binary"
@echo " build-benchmark - Build only the vex-benchmark binary"
@echo ""
@echo "Running:"
@echo " run - Run the server directly"
@echo " run-json - Run the server with JSON logging"
@echo " run-debug - Run the server with debug logging"
@echo ""
@echo "Benchmarking:"
@echo " bench - Run unit benchmarks then integration benchmarks"
@echo " bench-all - Run all unit benchmarks"
@echo " bench-unit - Run unit benchmarks (micro-level performance)"
@echo " bench-storage - Run storage layer benchmarks"
@echo " bench-integration - Run integration benchmarks (requires running server)"
@echo " benchmark - Run insert benchmark (legacy, same as: go run cmd/vex-benchmark)"
@echo " benchmark-search - Run search benchmark (legacy)"
@echo " benchmark-custom - Run custom benchmark with ARGS flag"
@echo ""
@echo "Testing:"
@echo " test - Run all tests"
@echo " test-coverage - Run tests with coverage report"
@echo " test-race - Run tests with race detector"
@echo " test-recall - Run HNSW recall@k accuracy tests"
@echo " test-recall-report - Generate detailed recall accuracy report"
@echo ""
@echo "Code Quality:"
@echo " fmt - Format all Go code"
@echo " vet - Run go vet"
@echo " lint - Run golangci-lint"
@echo " tidy - Tidy Go modules"
@echo " verify - Run all verification checks locally (test, lint, race)"
@echo ""
@echo "Maintenance:"
@echo " clean - Clean build artifacts"
@echo " install-tools - Install development tools"
@echo " help - Show this help message"
# Run all verify checks locally (mirrors GitHub Actions CI)
verify: tidy fmt vet
@echo "=== Running CI checks locally ==="
@echo ""
@echo ">>> Running tests with race detector..."
$(GOTEST) -v -race -coverprofile=coverage.out ./internal/...
@echo ""
@echo ">>> Running golangci-lint..."
golangci-lint run ./...
@echo ""
@echo ">>> Coverage Summary:"
@$(GOCMD) tool cover -func=coverage.out | tail -n 1
@echo ""
@echo "=== All CI checks passed! ==="