Skip to content

Commit a747e2d

Browse files
authored
Merge pull request #86 from weaviate/iteration_id
Store iteration ID and make use of Hfresh term
2 parents 83e53ef + 8bc0d8c commit a747e2d

3 files changed

Lines changed: 23 additions & 25 deletions

File tree

benchmarker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Flags:
4848
-h, --help help for ann-benchmark
4949
--httpOrigin string The http origin for Weaviate (only used if grpc enabled) (default "localhost:8080")
5050
--httpScheme string The http scheme (http or https) (default "http")
51-
--indexType string Index type (hnsw, flat, spfresh) (default "hnsw")
51+
--indexType string Index type (hnsw, flat, hfresh) (default "hnsw")
5252
--labels string Labels of format key1=value1,key2=value2,...
5353
-l, --limit int Set the query limit / k (default 10) (default 10)
5454
--maxConnections int Set Weaviate efConstruction parameter (default 16) (default 16)

benchmarker/cmd/ann_benchmark.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type ResultsJSONBenchmark struct {
6464
Limit int `json:"limit"`
6565
ImportTime float64 `json:"importTime"`
6666
RunID string `json:"run_id"`
67+
IterationRunID string `json:"iteration"`
6768
Dataset string `json:"dataset_file"`
6869
Recall float64 `json:"recall"`
6970
NDCG float64 `json:"ndcg"`
@@ -713,7 +714,7 @@ func parseEfValues(s string) ([]int, error) {
713714
}
714715

715716
func runQueries(cfg *Config, importTime time.Duration, testData [][]float32, neighbors [][]int, filters []int) {
716-
baseRunID := strconv.FormatInt(time.Now().Unix(), 10)
717+
runID := strconv.FormatInt(time.Now().Unix(), 10)
717718

718719
efCandidates, err := parseEfValues(cfg.EfArray)
719720
if err != nil {
@@ -742,13 +743,9 @@ func runQueries(cfg *Config, importTime time.Duration, testData [][]float32, nei
742743
}
743744

744745
iteration++
745-
runID := fmt.Sprintf("%s-%d", baseRunID, iteration)
746+
iterationRunID := fmt.Sprintf("%d", iteration)
746747
isFinalIteration := !cfg.WaitForBackground || shouldStop
747748

748-
if isFinalIteration {
749-
runID = fmt.Sprintf("%s-true", runID)
750-
}
751-
752749
benchmarkResultsMap := make([]map[string]interface{}, 0, len(efCandidates))
753750
for _, ef := range efCandidates {
754751
updateEf(ef, cfg, client)
@@ -797,6 +794,7 @@ func runQueries(cfg *Config, importTime time.Duration, testData [][]float32, nei
797794
Limit: cfg.Limit,
798795
ImportTime: importTime.Seconds(),
799796
RunID: runID,
797+
IterationRunID: iterationRunID,
800798
Dataset: dataset,
801799
NDCG: result.NDCG,
802800
Recall: result.Recall,
@@ -862,9 +860,9 @@ func shouldStopRunQueries(iteration int, cfg *Config) bool {
862860
return false
863861
}
864862

865-
metrics, err := readSPFreshMetrics(cfg)
863+
metrics, err := readHFreshMetrics(cfg)
866864
if err != nil {
867-
log.WithError(err).Warn("Failed to read SPFresh pending operations metrics")
865+
log.WithError(err).Warn("Failed to read HFresh pending operations metrics")
868866
return false
869867
}
870868

@@ -875,16 +873,16 @@ func shouldStopRunQueries(iteration int, cfg *Config) bool {
875873
if noPendingOps {
876874
log.WithFields(log.Fields{
877875
"iteration": iteration,
878-
}).Info("All SPFresh background operations complete")
876+
}).Info("All HFresh background operations complete")
879877
return true
880878
}
881879

882880
secs := 30
883881

884882
for {
885-
metrics, err := readSPFreshMetrics(cfg)
883+
metrics, err := readHFreshMetrics(cfg)
886884
if err != nil {
887-
log.WithError(err).Warn("Failed to read SPFresh pending operations metrics")
885+
log.WithError(err).Warn("Failed to read HFresh pending operations metrics")
888886
return false
889887
}
890888

@@ -893,7 +891,7 @@ func shouldStopRunQueries(iteration int, cfg *Config) bool {
893891
"pendingSplitOperations": metrics.PendingSplitOperations,
894892
"pendingMergeOperations": metrics.PendingMergeOperations,
895893
"pendingReassignOperations": metrics.PendingReassignOperations,
896-
}).Info("SPFresh background operations still running, checking again in ", secs, " seconds")
894+
}).Info("HFresh background operations still running, checking again in ", secs, " seconds")
897895
noPendingOps := metrics.PendingSplitOperations == 0 &&
898896
metrics.PendingMergeOperations == 0 &&
899897
metrics.PendingReassignOperations == 0
@@ -1078,7 +1076,7 @@ func initAnnBenchmark() {
10781076
annBenchmarkCommand.PersistentFlags().StringVar(&globalConfig.EfArray,
10791077
"efArray", "16,24,32,48,64,96,128,256,512", "Array of ef parameters as comma separated list")
10801078
annBenchmarkCommand.PersistentFlags().StringVar(&globalConfig.IndexType,
1081-
"indexType", "hnsw", "Index type (hnsw, flat or spfresh)")
1079+
"indexType", "hnsw", "Index type (hnsw, flat or hfresh)")
10821080
annBenchmarkCommand.PersistentFlags().IntVar(&globalConfig.MaxConnections,
10831081
"maxConnections", 16, "Set Weaviate efConstruction parameter (default 16)")
10841082
annBenchmarkCommand.PersistentFlags().IntVar(&globalConfig.Shards,
@@ -1142,13 +1140,13 @@ func initAnnBenchmark() {
11421140
annBenchmarkCommand.PersistentFlags().StringVar(&globalConfig.Dataset,
11431141
"dataset", "", "Dataset name e.g. dbpedia-openai-ada002-1536-float32-angular-100k")
11441142
annBenchmarkCommand.PersistentFlags().IntVar(&globalConfig.MaxPostingSize,
1145-
"maxPostingSize", 0, "Max posting size for SPFresh index (default 0)")
1143+
"maxPostingSize", 0, "Max posting size for HFresh index (default 0)")
11461144
annBenchmarkCommand.PersistentFlags().IntVar(&globalConfig.MinPostingSize,
1147-
"minPostingSize", 10, "Min posting size for SPFresh index (default 10)")
1145+
"minPostingSize", 10, "Min posting size for HFresh index (default 10)")
11481146
annBenchmarkCommand.PersistentFlags().IntVar(&globalConfig.Replicas,
1149-
"replicas", 8, "Number of replicas for SPFresh index (default 8)")
1147+
"replicas", 8, "Number of replicas for HFresh index (default 8)")
11501148
annBenchmarkCommand.PersistentFlags().Float64Var(&globalConfig.RngFactor,
1151-
"rngFactor", 10.0, "RNG factor for SPFresh index (default 10.0)")
1149+
"rngFactor", 10.0, "RNG factor for HFresh index (default 10.0)")
11521150
}
11531151

11541152
func benchmarkANN(cfg Config, queries Queries, neighbors Neighbors, filters []int) Results {

benchmarker/cmd/metrics.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ func readMemoryMetrics(cfg *Config) (*Memstats, error) {
5858
return &memstats, nil
5959
}
6060

61-
type SPFreshPendingMetrics struct {
61+
type HFreshPendingMetrics struct {
6262
PendingSplitOperations int `json:"pending_split_operations"`
6363
PendingMergeOperations int `json:"pending_merge_operations"`
6464
PendingReassignOperations int `json:"pending_reassign_operations"`
6565
}
6666

67-
func readSPFreshMetrics(cfg *Config) (*SPFreshPendingMetrics, error) {
67+
func readHFreshMetrics(cfg *Config) (*HFreshPendingMetrics, error) {
6868
prometheusURL := fmt.Sprintf("http://%s/metrics", strings.Replace(cfg.HttpOrigin, "8080", "2112", -1))
6969
response, err := http.Get(prometheusURL)
7070
if err != nil {
@@ -88,7 +88,7 @@ func readSPFreshMetrics(cfg *Config) (*SPFreshPendingMetrics, error) {
8888
return nil, err
8989
}
9090

91-
var spfreshMetrics SPFreshPendingMetrics
91+
var hfreshMetrics HFreshPendingMetrics
9292

9393
if metric, ok := metrics["vector_index_pending_background_operations"]; ok {
9494
for _, m := range metric.Metric {
@@ -105,16 +105,16 @@ func readSPFreshMetrics(cfg *Config) (*SPFreshPendingMetrics, error) {
105105
value := int(m.GetGauge().GetValue())
106106
switch op {
107107
case "split":
108-
spfreshMetrics.PendingSplitOperations = value
108+
hfreshMetrics.PendingSplitOperations = value
109109
case "merge":
110-
spfreshMetrics.PendingMergeOperations = value
110+
hfreshMetrics.PendingMergeOperations = value
111111
case "reassign":
112-
spfreshMetrics.PendingReassignOperations = value
112+
hfreshMetrics.PendingReassignOperations = value
113113
}
114114
}
115115
}
116116

117-
return &spfreshMetrics, nil
117+
return &hfreshMetrics, nil
118118
}
119119

120120
func waitTombstonesEmpty(cfg *Config) error {

0 commit comments

Comments
 (0)