From a1873dd6f65654d463455ae2d381c35c12f71f51 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Thu, 15 May 2014 14:04:57 -0600 Subject: Add option to adjust fill percentage. This commit adds the ability to adjust the fill percentage for splitting nodes. This works by setting a threshold that is a percentage of a total page size. When that threshold is crossed during a split then a new node is created. This is primarily beneficial for append-only workloads. Fixes #163. --- node.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'node.go') diff --git a/node.go b/node.go index 5ad581e..e345d7f 100644 --- a/node.go +++ b/node.go @@ -215,8 +215,14 @@ func (n *node) split(pageSize int) []*node { return nodes } - // Set fill threshold to 50%. - threshold := pageSize / 2 + // Determine the threshold before starting a new node. + var fillPercent = n.bucket.tx.db.FillPercent + if fillPercent < minFillPercent { + fillPercent = minFillPercent + } else if fillPercent > maxFillPercent { + fillPercent = maxFillPercent + } + threshold := int(float64(pageSize) * fillPercent) // Group into smaller pages and target a given fill size. size := pageHeaderSize -- cgit v1.2.3