Skip to content

Commit 33ba5ba

Browse files
zeeboStorj Robot
authored andcommitted
storagenode/hashstore: remove monkit from hashtbl
the benchmarks speak for themselves. name old time/op new time/op delta Compact/lrec=17 767ms ± 4% 349ms ± 2% -54.54% Compact/lrec=18 1.47s ± 2% 0.63s ± 8% -57.21% Compact/lrec=19 2.84s ± 3% 1.18s ± 3% -58.48% Compact/lrec=20 5.58s ± 3% 2.12s ± 3% -62.04% Compact/lrec=21 11.1s ± 1% 4.1s ±12% -62.94% Compact/lrec=22 21.8s ± 1% 7.7s ± 3% -64.74% Compact/lrec=23 44.0s ± 2% 15.1s ± 3% -65.67% name old alloc/op new alloc/op delta Compact/lrec=17 36.7MB ± 0% 1.1MB ± 0% -97.09% Compact/lrec=18 72.4MB ± 0% 1.1MB ± 0% -98.53% Compact/lrec=19 144MB ± 0% 1MB ± 0% -99.26% Compact/lrec=20 286MB ± 0% 1MB ± 0% -99.63% Compact/lrec=21 571MB ± 0% 1MB ± 0% -99.81% Compact/lrec=22 1.14GB ± 0% 0.00GB ± 0% -99.91% Compact/lrec=23 2.28GB ± 0% 0.00GB ± 0% -99.95% name old allocs/op new allocs/op delta Compact/lrec=17 655k ± 0% 0k ± 2% -99.99% Compact/lrec=18 1.31M ± 0% 0.00M ± 2% -99.99% Compact/lrec=19 2.62M ± 0% 0.00M ± 3% -100.00% Compact/lrec=20 5.24M ± 0% 0.00M ± 7% -100.00% Compact/lrec=21 10.5M ± 0% 0.0M ± 3% -100.00% Compact/lrec=22 21.0M ± 0% 0.0M ± 4% -100.00% Compact/lrec=23 41.9M ± 0% 0.0M ± 3% -100.00% name old rec/sec new rec/sec delta Compact/lrec=17 171k ± 4% 376k ± 2% +119.93% Compact/lrec=18 178k ± 2% 416k ± 8% +134.00% Compact/lrec=19 184k ± 3% 444k ± 3% +140.86% Compact/lrec=20 188k ± 3% 495k ± 2% +163.41% Compact/lrec=21 189k ± 1% 512k ±11% +171.06% Compact/lrec=22 193k ± 1% 547k ± 3% +183.69% Compact/lrec=23 191k ± 2% 555k ± 3% +191.26% Change-Id: Ib3f895ee15fd36c5e55fbe7f54d03b39a6649f5b
1 parent 32bd2bf commit 33ba5ba

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

storagenode/hashstore/hashtbl.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -317,12 +317,8 @@ func (h *HashTbl) Load() float64 {
317317
return float64(h.numSet) / float64(h.numSlots)
318318
}
319319

320-
var rangeTask = mon.Task()
321-
322320
// Range iterates over the records in hash table order.
323321
func (h *HashTbl) Range(fn func(Record, error) bool) {
324-
defer rangeTask(nil)(nil)
325-
326322
h.opMu.RLock()
327323
defer h.opMu.RUnlock()
328324

@@ -387,14 +383,10 @@ func (h *HashTbl) ExpectOrdered() (flush func() error, done func(), err error) {
387383
}, nil
388384
}
389385

390-
var insertTask = mon.Task()
391-
392386
// Insert adds a record to the hash table. It returns (true, nil) if the record was inserted, it
393387
// returns (false, nil) if the hash table is full, and (false, err) if any errors happened trying
394388
// to insert the record.
395389
func (h *HashTbl) Insert(rec Record) (_ bool, err error) {
396-
defer insertTask(nil)(&err)
397-
398390
h.opMu.Lock()
399391
defer h.opMu.Unlock()
400392

@@ -485,14 +477,10 @@ func (h *HashTbl) Insert(rec Record) (_ bool, err error) {
485477
return false, nil
486478
}
487479

488-
var lookupTask = mon.Task()
489-
490480
// Lookup returns the record for the given key if it exists in the hash table. It returns (rec,
491481
// true, nil) if the record existed, (rec{}, false, nil) if it did not exist, and (rec{}, false,
492482
// err) if any errors happened trying to look up the record.
493483
func (h *HashTbl) Lookup(key Key) (_ Record, _ bool, err error) {
494-
defer lookupTask(nil)(&err)
495-
496484
h.opMu.RLock()
497485
defer h.opMu.RUnlock()
498486

storagenode/hashstore/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (h *Writer) Close() (err error) {
306306

307307
// if we are not in manual mode, then we need to add the record.
308308
if !h.manual {
309-
if err := h.store.addRecord(ctx, h.rec); err != nil {
309+
if err := h.store.addRecord(h.rec); err != nil {
310310
// if we can't add the record, we should abort the write operation and attempt to
311311
// reclaim space by seeking backwards to the record offset.
312312
_, _ = h.lf.fh.Seek(int64(size), io.SeekStart)

storagenode/hashstore/store.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,7 @@ func (s *Store) acquireLogFile(ttl uint32) (*logFile, error) {
331331
return lf, err
332332
}
333333

334-
func (s *Store) addRecord(ctx context.Context, rec Record) error {
335-
// sometimes a Writer is created with a nil store so that it can disable automatically writing
336-
// records.
337-
if s == nil {
338-
return nil
339-
}
340-
334+
func (s *Store) addRecord(rec Record) error {
341335
ok, err := s.tbl.Insert(rec)
342336
if err != nil {
343337
return Error.Wrap(err)
@@ -539,7 +533,7 @@ func (s *Store) reviveRecord(ctx context.Context, lf *logFile, rec Record) (err
539533
}
540534

541535
tmp.Expires = 0
542-
return s.addRecord(ctx, tmp)
536+
return s.addRecord(tmp)
543537
}
544538

545539
// 4. otherwise, we either had an error looking up the current record, or the entry got fully

storagenode/hashstore/store_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,9 @@ func BenchmarkStore(b *testing.B) {
10431043
defer s.Close()
10441044

10451045
for i := uint64(0); i < 1<<lrec; i++ {
1046-
s.AssertCreate()
1046+
wr, err := s.Create(context.Background(), newKey(), time.Time{})
1047+
assert.NoError(b, err)
1048+
assert.NoError(b, wr.Close())
10471049
if s.Load() > 0.5 {
10481050
s.AssertCompact(nil, time.Time{})
10491051
}
@@ -1065,5 +1067,4 @@ func BenchmarkStore(b *testing.B) {
10651067

10661068
b.ReportMetric(float64(b.N*int(1)<<lrec)/time.Since(now).Seconds(), "rec/sec")
10671069
})
1068-
10691070
}

0 commit comments

Comments
 (0)