@@ -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
0 commit comments