From 5a7ab0d90bb403977bf88404813ef1793aa2c0a2 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin <valyala@gmail.com> Date: Tue, 13 Aug 2019 20:20:51 +0300 Subject: [PATCH] lib/storage: remove broken BenchmarkIndexDBSearchTSIDs --- lib/storage/index_db_timing_test.go | 81 ----------------------------- 1 file changed, 81 deletions(-) diff --git a/lib/storage/index_db_timing_test.go b/lib/storage/index_db_timing_test.go index 19e973a260..2466d0dd74 100644 --- a/lib/storage/index_db_timing_test.go +++ b/lib/storage/index_db_timing_test.go @@ -81,87 +81,6 @@ func benchmarkIndexDBAddTSIDs(db *indexDB, tsid *TSID, mn *MetricName, startOffs } } -func BenchmarkIndexDBSearchTSIDs(b *testing.B) { - metricIDCache := fastcache.New(1234) - metricNameCache := fastcache.New(1234) - defer metricIDCache.Reset() - defer metricNameCache.Reset() - - var hmCurr atomic.Value - hmCurr.Store(&hourMetricIDs{}) - var hmPrev atomic.Value - hmPrev.Store(&hourMetricIDs{}) - - const dbName = "bench-index-db-search-tsids" - db, err := openIndexDB(dbName, metricIDCache, metricNameCache, &hmCurr, &hmPrev) - if err != nil { - b.Fatalf("cannot open indexDB: %s", err) - } - defer func() { - db.MustClose() - if err := os.RemoveAll(dbName); err != nil { - b.Fatalf("cannot remove indexDB: %s", err) - } - }() - - const accountsCount = 111 - const projectsCount = 33333 - const recordsCount = 1e5 - - // Fill the db with recordsCount records. - var mn MetricName - mn.MetricGroup = []byte("rps") - for i := 0; i < 2; i++ { - key := fmt.Sprintf("key_%d", i) - value := fmt.Sprintf("value_%d", i) - mn.AddTag(key, value) - } - var tsid TSID - var metricName []byte - is := db.getIndexSearch() - defer db.putIndexSearch(is) - for i := 0; i < recordsCount; i++ { - mn.AccountID = uint32(i % accountsCount) - mn.ProjectID = uint32(i % projectsCount) - mn.sortTags() - metricName = mn.Marshal(metricName[:0]) - if err := is.GetOrCreateTSIDByName(&tsid, metricName); err != nil { - b.Fatalf("cannot insert record: %s", err) - } - } - - b.SetBytes(1) - b.ReportAllocs() - b.ResetTimer() - b.RunParallel(func(pb *testing.PB) { - tags := []Tag{ - {[]byte("key_0"), []byte("value_0")}, - {[]byte("key_1"), []byte("value_1")}, - } - var tfs TagFilters - tfss := []*TagFilters{&tfs} - i := 0 - for pb.Next() { - accountID := uint32(i % accountsCount) - projectID := uint32(i % projectsCount) - tfs.Reset(accountID, projectID) - for j := range tags { - if err := tfs.Add(tags[j].Key, tags[j].Value, false, false); err != nil { - panic(fmt.Errorf("BUG: unexpected error: %s", err)) - } - } - tsids, err := db.searchTSIDs(tfss, TimeRange{}, 1e5) - if err != nil { - panic(fmt.Errorf("unexpected error in search for tfs=%s: %s", &tfs, err)) - } - if len(tsids) == 0 && i < recordsCount { - panic(fmt.Errorf("zero tsids found for tfs=%s", &tfs)) - } - i++ - } - }) -} - func BenchmarkIndexDBGetTSIDs(b *testing.B) { metricIDCache := fastcache.New(1234) metricNameCache := fastcache.New(1234)