Skip to content

Commit 3a8e104

Browse files
committed
lint
Signed-off-by: bitliu <[email protected]>
1 parent af9fca5 commit 3a8e104

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/semantic-router/pkg/cache/cache_test.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,7 +1734,9 @@ func BenchmarkHybridVsMilvus(b *testing.B) {
17341734
}
17351735
}
17361736
resultsDir := filepath.Join(projectRoot, "benchmark_results", "hybrid_vs_milvus")
1737-
os.MkdirAll(resultsDir, 0755)
1737+
if err := os.MkdirAll(resultsDir, 0755); err != nil {
1738+
b.Logf("Warning: Could not create results directory: %v", err)
1739+
}
17381740
timestamp := time.Now().Format("20060102_150405")
17391741
csvPath := filepath.Join(resultsDir, fmt.Sprintf("results_%s.csv", timestamp))
17401742
csvFile, err := os.Create(csvPath)
@@ -1744,7 +1746,9 @@ func BenchmarkHybridVsMilvus(b *testing.B) {
17441746
defer csvFile.Close()
17451747
b.Logf("Results will be saved to: %s", csvPath)
17461748
// Write CSV header
1747-
csvFile.WriteString("cache_type,cache_size,operation,avg_latency_ns,avg_latency_ms,p50_ms,p95_ms,p99_ms,qps,memory_mb,hit_rate,db_calls,total_requests,db_call_percent\n")
1749+
if _, err := csvFile.WriteString("cache_type,cache_size,operation,avg_latency_ns,avg_latency_ms,p50_ms,p95_ms,p99_ms,qps,memory_mb,hit_rate,db_calls,total_requests,db_call_percent\n"); err != nil {
1750+
b.Logf("Warning: Could not write CSV header: %v", err)
1751+
}
17481752
}
17491753

17501754
b.Logf("=== Hybrid Cache vs Pure Milvus Benchmark ===")
@@ -2174,7 +2178,7 @@ func BenchmarkComponentLatency(b *testing.B) {
21742178

21752179
b.Logf("Building HNSW index with %d entries...", cacheSize)
21762180
for i := 0; i < cacheSize; i++ {
2177-
cache.AddEntry(fmt.Sprintf("req-%d", i), "model", testQueries[i], []byte("req"), []byte("resp"))
2181+
_ = cache.AddEntry(fmt.Sprintf("req-%d", i), "model", testQueries[i], []byte("req"), []byte("resp"))
21782182
}
21792183
b.Logf("✓ HNSW index built")
21802184

@@ -2184,7 +2188,7 @@ func BenchmarkComponentLatency(b *testing.B) {
21842188
start := time.Now()
21852189
for i := 0; i < b.N; i++ {
21862190
// Note: HNSW search uses entries slice internally
2187-
cache.FindSimilar("model", query)
2191+
_, _, _ = cache.FindSimilar("model", query)
21882192
}
21892193
elapsed := time.Since(start)
21902194
avgMs := float64(elapsed.Nanoseconds()) / float64(b.N) / 1e6
@@ -2208,7 +2212,7 @@ func BenchmarkComponentLatency(b *testing.B) {
22082212

22092213
b.Logf("Populating Milvus with %d entries...", cacheSize)
22102214
for i := 0; i < cacheSize; i++ {
2211-
milvusCache.AddEntry(fmt.Sprintf("req-%d", i), "model", testQueries[i], []byte("req"), []byte("resp"))
2215+
_ = milvusCache.AddEntry(fmt.Sprintf("req-%d", i), "model", testQueries[i], []byte("req"), []byte("resp"))
22122216
}
22132217
time.Sleep(2 * time.Second)
22142218
b.Logf("✓ Milvus populated")
@@ -2218,7 +2222,7 @@ func BenchmarkComponentLatency(b *testing.B) {
22182222
b.ResetTimer()
22192223
start := time.Now()
22202224
for i := 0; i < b.N; i++ {
2221-
milvusCache.FindSimilar("model", query)
2225+
_, _, _ = milvusCache.FindSimilar("model", query)
22222226
}
22232227
elapsed := time.Since(start)
22242228
avgMs := float64(elapsed.Nanoseconds()) / float64(b.N) / 1e6
@@ -2266,7 +2270,7 @@ func BenchmarkThroughputUnderLoad(b *testing.B) {
22662270

22672271
// Populate
22682272
for i := 0; i < cacheSize; i++ {
2269-
milvusCache.AddEntry(fmt.Sprintf("req-%d", i), "model", testQueries[i], []byte("req"), []byte("resp"))
2273+
_ = milvusCache.AddEntry(fmt.Sprintf("req-%d", i), "model", testQueries[i], []byte("req"), []byte("resp"))
22702274
}
22712275
time.Sleep(2 * time.Second)
22722276

@@ -2278,7 +2282,7 @@ func BenchmarkThroughputUnderLoad(b *testing.B) {
22782282
i := 0
22792283
for pb.Next() {
22802284
query := testQueries[i%len(testQueries)]
2281-
milvusCache.FindSimilar("model", query)
2285+
_, _, _ = milvusCache.FindSimilar("model", query)
22822286
i++
22832287
}
22842288
})
@@ -2308,7 +2312,7 @@ func BenchmarkThroughputUnderLoad(b *testing.B) {
23082312

23092313
// Populate
23102314
for i := 0; i < cacheSize; i++ {
2311-
hybridCache.AddEntry(fmt.Sprintf("req-%d", i), "model", testQueries[i], []byte("req"), []byte("resp"))
2315+
_ = hybridCache.AddEntry(fmt.Sprintf("req-%d", i), "model", testQueries[i], []byte("req"), []byte("resp"))
23122316
}
23132317
time.Sleep(2 * time.Second)
23142318

@@ -2320,7 +2324,7 @@ func BenchmarkThroughputUnderLoad(b *testing.B) {
23202324
i := 0
23212325
for pb.Next() {
23222326
query := testQueries[i%len(testQueries)]
2323-
hybridCache.FindSimilar("model", query)
2327+
_, _, _ = hybridCache.FindSimilar("model", query)
23242328
i++
23252329
}
23262330
})
@@ -2374,7 +2378,10 @@ func writeBenchmarkResultToCSV(file *os.File, result BenchmarkResult) {
23742378
result.TotalRequests,
23752379
result.DatabaseCallPercent,
23762380
)
2377-
file.WriteString(line)
2381+
if _, err := file.WriteString(line); err != nil {
2382+
// Ignore write errors in benchmark helper
2383+
_ = err
2384+
}
23782385
}
23792386

23802387
// TestHybridVsMilvusSmoke is a quick smoke test to verify both caches work

src/semantic-router/pkg/extproc/stream_handling_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import (
1717
. "github.com/onsi/gomega"
1818
"github.com/openai/openai-go"
1919
"github.com/prometheus/client_golang/prometheus"
20+
dto "github.com/prometheus/client_model/go"
2021
"github.com/stretchr/testify/assert"
2122
"google.golang.org/grpc/codes"
2223
"google.golang.org/grpc/metadata"
2324
"google.golang.org/grpc/status"
2425

25-
dto "github.com/prometheus/client_model/go"
2626
candle_binding "github.com/vllm-project/semantic-router/candle-binding"
2727
"github.com/vllm-project/semantic-router/src/semantic-router/pkg/cache"
2828
"github.com/vllm-project/semantic-router/src/semantic-router/pkg/classification"

src/semantic-router/pkg/extproc/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package extproc
22

33
import (
44
ext_proc "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3"
5+
56
"github.com/vllm-project/semantic-router/src/semantic-router/pkg/observability/logging"
67
)
78

0 commit comments

Comments
 (0)