forked from TrueCloudLab/frostfs-node
[#1516] metabase: Cache graveyard buckets in ListWithCursor
``` name old time/op new time/op delta ListWithCursor/1_item-8 6.40µs ±13% 6.45µs ±14% ~ (p=0.739 n=10+10) ListWithCursor/10_items-8 30.9µs ±21% 20.9µs ±17% -32.49% (p=0.000 n=10+10) ListWithCursor/100_items-8 274µs ±27% 153µs ±12% -44.09% (p=0.000 n=10+10) name old alloc/op new alloc/op delta ListWithCursor/1_item-8 2.26kB ± 0% 2.31kB ± 0% +2.46% (p=0.000 n=10+10) ListWithCursor/10_items-8 10.8kB ± 0% 6.9kB ± 0% -36.07% (p=0.000 n=8+8) ListWithCursor/100_items-8 96.8kB ± 0% 53.3kB ± 0% -44.98% (p=0.000 n=10+10) name old allocs/op new allocs/op delta ListWithCursor/1_item-8 39.0 ± 0% 40.0 ± 0% +2.56% (p=0.000 n=10+10) ListWithCursor/10_items-8 192 ± 0% 121 ± 0% -36.98% (p=0.000 n=10+10) ListWithCursor/100_items-8 1.72k ± 0% 0.93k ± 0% -45.93% (p=0.000 n=10+10) ``` Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru> name old time/op new time/op delta ListWithCursor/1_item-8 5.23µs ±19% 5.26µs ±15% ~ (p=0.853 n=10+10) ListWithCursor/10_items-8 27.2µs ±15% 18.0µs ±19% -33.80% (p=0.000 n=10+10) ListWithCursor/100_items-8 250µs ±13% 139µs ±15% -44.27% (p=0.000 n=10+10) name old alloc/op new alloc/op delta ListWithCursor/1_item-8 1.99kB ± 0% 2.04kB ± 0% +2.82% (p=0.000 n=8+8) ListWithCursor/10_items-8 10.3kB ± 0% 6.4kB ± 0% -37.83% (p=0.000 n=8+10) ListWithCursor/100_items-8 93.9kB ± 0% 50.4kB ± 0% -46.37% (p=0.000 n=10+10) name old allocs/op new allocs/op delta ListWithCursor/1_item-8 35.0 ± 0% 36.0 ± 0% +2.86% (p=0.000 n=10+10) ListWithCursor/10_items-8 184 ± 0% 113 ± 0% -38.59% (p=0.000 n=10+10) ListWithCursor/100_items-8 1.67k ± 0% 0.88k ± 0% -47.29% (p=0.000 n=10+10) ``` Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
af4db8a73b
commit
a93373fe71
2 changed files with 8 additions and 5 deletions
|
@ -105,12 +105,13 @@ func (db *DB) exists(tx *bbolt.Tx, addr oid.Address) (exists bool, err error) {
|
|||
// * 1 if object with GC mark;
|
||||
// * 2 if object is covered with tombstone.
|
||||
func inGraveyard(tx *bbolt.Tx, addr oid.Address) uint8 {
|
||||
graveyardBkt := tx.Bucket(graveyardBucketName)
|
||||
garbageBkt := tx.Bucket(garbageBucketName)
|
||||
addrKey := addressKey(addr)
|
||||
return inGraveyardWithKey(tx, addrKey)
|
||||
return inGraveyardWithKey(addrKey, graveyardBkt, garbageBkt)
|
||||
}
|
||||
|
||||
func inGraveyardWithKey(tx *bbolt.Tx, addrKey []byte) uint8 {
|
||||
graveyard := tx.Bucket(graveyardBucketName)
|
||||
func inGraveyardWithKey(addrKey []byte, graveyard, garbageBCK *bbolt.Bucket) uint8 {
|
||||
if graveyard == nil {
|
||||
// incorrect metabase state, does not make
|
||||
// sense to check garbage bucket
|
||||
|
@ -119,7 +120,6 @@ func inGraveyardWithKey(tx *bbolt.Tx, addrKey []byte) uint8 {
|
|||
|
||||
val := graveyard.Get(addrKey)
|
||||
if val == nil {
|
||||
garbageBCK := tx.Bucket(garbageBucketName)
|
||||
if garbageBCK == nil {
|
||||
// incorrect node state
|
||||
return 0
|
||||
|
|
|
@ -178,6 +178,9 @@ func selectNFromBucket(tx *bbolt.Tx,
|
|||
addrRaw := make([]byte, len(prefix)+44)
|
||||
copy(addrRaw, prefix)
|
||||
|
||||
graveyardBkt := tx.Bucket(graveyardBucketName)
|
||||
garbageBkt := tx.Bucket(garbageBucketName)
|
||||
|
||||
for ; k != nil; k, _ = c.Next() {
|
||||
if count >= limit {
|
||||
break
|
||||
|
@ -190,7 +193,7 @@ func selectNFromBucket(tx *bbolt.Tx,
|
|||
|
||||
offset = k
|
||||
addrRaw = append(addrRaw[:len(prefix)], k...)
|
||||
if inGraveyardWithKey(tx, addrRaw) > 0 {
|
||||
if inGraveyardWithKey(addrRaw, graveyardBkt, garbageBkt) > 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue