Skip to content

Commit

Permalink
recsplit: change default BucketSize (#13272)
Browse files Browse the repository at this point in the history
Params:
- change default BucketSize: at `100` i don't see any size grow. but
build speed -30% and read speed -20%
- keep same default LeafSize: it increasing build speed, but decreasing
reads speed. so we do preoritize reads speed.
  • Loading branch information
AskAlexSharov authored Dec 30, 2024
1 parent 6f33aa7 commit 0e548a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions erigon-lib/kv/mdbx/kv_mdbx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ func (tx *MdbxTx) stdCursor(bucket string) (kv.RwCursor, error) {
c := &MdbxCursor{bucketName: bucket, tx: tx, bucketCfg: b, id: tx.ID}
tx.ID++

if tx.tx == nil {
panic("assert: tx.tx nil. seems this `tx` was Rollback'ed")
}
var err error
c.c, err = tx.tx.OpenCursor(mdbx.DBI(tx.db.buckets[c.bucketName].DBI))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/recsplit/recsplit.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ type RecSplitArgs struct {
// DefaultLeafSize - LeafSize=8 and BucketSize=100, use abount 1.8 bits per key. Increasing the leaf and bucket
// sizes gives more compact structures (1.56 bits per key), at the price of a slower construction time
const DefaultLeafSize = 8
const DefaultBucketSize = 2000 // typical from 100 to 2000, with smaller buckets giving slightly larger but faster function
const DefaultBucketSize = 100 // typical from 100 to 2000, with smaller buckets giving slightly larger but faster function

// NewRecSplit creates a new RecSplit instance with given number of keys and given bucket size
// Typical bucket size is 100 - 2000, larger bucket sizes result in smaller representations of hash functions, at a cost of slower access
Expand Down
6 changes: 3 additions & 3 deletions erigon-lib/state/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,13 @@ func TestAggregatorV3_PruneSmallBatches(t *testing.T) {
require.NoError(t, err)
codeRangeAfter = extractKVErrIterator(t, it)

its, err := ac.d[kv.AccountsDomain].ht.HistoryRange(0, int(maxTx), order.Asc, maxInt, tx)
its, err := ac.d[kv.AccountsDomain].ht.HistoryRange(0, int(maxTx), order.Asc, maxInt, afterTx)
require.NoError(t, err)
accountHistRangeAfter = extractKVSErrIterator(t, its)
its, err = ac.d[kv.CodeDomain].ht.HistoryRange(0, int(maxTx), order.Asc, maxInt, tx)
its, err = ac.d[kv.CodeDomain].ht.HistoryRange(0, int(maxTx), order.Asc, maxInt, afterTx)
require.NoError(t, err)
codeHistRangeAfter = extractKVSErrIterator(t, its)
its, err = ac.d[kv.StorageDomain].ht.HistoryRange(0, int(maxTx), order.Asc, maxInt, tx)
its, err = ac.d[kv.StorageDomain].ht.HistoryRange(0, int(maxTx), order.Asc, maxInt, afterTx)
require.NoError(t, err)
storageHistRangeAfter = extractKVSErrIterator(t, its)
}
Expand Down

0 comments on commit 0e548a4

Please sign in to comment.