diff options
author | EuAndreh <eu@euandre.org> | 2024-12-30 20:23:23 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-12-30 20:24:51 -0300 |
commit | 1641f980a6f622a201c7b8e67a9ce5da634aaaaa (patch) | |
tree | d54257de88d1f08741c64173cbddf1bb81c884c6 | |
parent | src/dedo.go: Remove DB.MmapFlags option (diff) | |
download | dedo-1641f980a6f622a201c7b8e67a9ce5da634aaaaa.tar.gz dedo-1641f980a6f622a201c7b8e67a9ce5da634aaaaa.tar.xz |
src/dedo.go: Remove Bucket.FillPercent option
-rw-r--r-- | src/dedo.go | 33 | ||||
-rw-r--r-- | tests/dedo.go | 2 |
2 files changed, 4 insertions, 31 deletions
diff --git a/src/dedo.go b/src/dedo.go index f6351e3..437680b 100644 --- a/src/dedo.go +++ b/src/dedo.go @@ -25,9 +25,6 @@ import ( "unicode" "unicode/utf8" "unsafe" - - - g "gobang" ) @@ -52,13 +49,6 @@ type Bucket struct { page *page // inline page reference rootNode *node // materialized node for the root page. nodes map[pgid]*node // node cache - - // Sets the threshold for filling nodes when they split. By default, - // the bucket will fill to 50% but it can be useful to increase this - // amount if you know that your write workloads are mostly append-only. - // - // This is non-persisted across transactions so it must be set in every Tx. - FillPercent float64 } // BucketStats records statistics about resources used by a bucket. @@ -425,7 +415,6 @@ type BenchOptions struct { MemProfile string BlockProfile string StatsInterval time.Duration - FillPercent float64 Work bool Path string } @@ -481,13 +470,6 @@ const ( bucketHeaderSize = int(unsafe.Sizeof(bucket{})) - minFillPercent = 0.1 - maxFillPercent = 1.0 - - // DefaultFillPercent is the percentage that split pages are filled. - // This value can be changed by setting Bucket.FillPercent. - DefaultFillPercent = 0.5 - // The largest step that can be taken when remapping the mmap. maxMmapStep = 1 << 30 // 1GB @@ -725,7 +707,7 @@ func madvise(b []byte, advice int) (err error) { // newBucket returns a new bucket associated with a transaction. func newBucket(tx *Tx) Bucket { - var b = Bucket{tx: tx, FillPercent: DefaultFillPercent} + var b = Bucket{tx: tx} if tx.writable { b.buckets = make(map[string]*Bucket) b.nodes = make(map[pgid]*node) @@ -848,7 +830,6 @@ func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) { var bucket = Bucket{ ref: &bucket{}, rootNode: &node{isLeaf: true}, - FillPercent: DefaultFillPercent, } var value = bucket.write() @@ -3132,18 +3113,14 @@ func (n *node) split(pageSize int) []*node { // splitTwo breaks up a node into two smaller nodes, if appropriate. // This should only be called from the split() function. func (n *node) splitTwo(pageSize int) (*node, *node) { + const fillPercent = 0.5 + // Ignore the split if the page doesn't have at least enough nodes for // two pages or if the nodes can fit in a single page. if len(n.inodes) <= (minKeysPerPage*2) || n.sizeLessThan(pageSize) { return n, nil } - // Determine the threshold before starting a new node. - fillPercent := g.Clamp( - n.bucket.FillPercent, - minFillPercent, - maxFillPercent, - ) threshold := int(float64(pageSize) * fillPercent) // Determine split position and sizes of the two pages. @@ -5035,7 +5012,6 @@ func (cmd *BenchCommand) ParseFlags(args []string) (*BenchOptions, error) { fs.StringVar(&options.CPUProfile, "cpuprofile", "", "") fs.StringVar(&options.MemProfile, "memprofile", "", "") fs.StringVar(&options.BlockProfile, "blockprofile", "", "") - fs.Float64Var(&options.FillPercent, "fill-percent", DefaultFillPercent, "") fs.BoolVar(&options.Work, "work", false, "") fs.StringVar(&options.Path, "path", "", "") fs.SetOutput(cmd.Stderr) @@ -5125,7 +5101,6 @@ func (cmd *BenchCommand) runWritesWithSource(db *DB, options *BenchOptions, resu for i := 0; i < options.Iterations; i += options.BatchSize { if err := db.Update(func(tx *Tx) error { b, _ := tx.CreateBucketIfNotExists(benchBucketName) - b.FillPercent = options.FillPercent for j := 0; j < options.BatchSize; j++ { key := make([]byte, options.KeySize) @@ -5157,7 +5132,6 @@ func (cmd *BenchCommand) runWritesNestedWithSource(db *DB, options *BenchOptions if err != nil { return err } - top.FillPercent = options.FillPercent // Create bucket key. name := make([]byte, options.KeySize) @@ -5168,7 +5142,6 @@ func (cmd *BenchCommand) runWritesNestedWithSource(db *DB, options *BenchOptions if err != nil { return err } - b.FillPercent = options.FillPercent for j := 0; j < options.BatchSize; j++ { var key = make([]byte, options.KeySize) diff --git a/tests/dedo.go b/tests/dedo.go index 719194e..c614cb9 100644 --- a/tests/dedo.go +++ b/tests/dedo.go @@ -1345,7 +1345,7 @@ func TestBucket_Stats_RandomFill(t *testing.T) { if err != nil { t.Fatal(err) } - b.FillPercent = 0.9 + for _, j := range rand.Perm(100) { index := (j * 10000) + i if err := b.Put([]byte(fmt.Sprintf("%d000000000000000", index)), []byte("0000000000")); err != nil { |