aboutsummaryrefslogtreecommitdiff
path: root/src/dedo.go
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-02-06 17:24:15 -0300
committerEuAndreh <eu@euandre.org>2025-02-06 17:24:15 -0300
commitf9d0e860d710c36d85e4a920861442fdc8102b30 (patch)
treeee4eb7e02de4599c7ceda964bb5a74effc8e0771 /src/dedo.go
parentsrc/dedo.go: Remove StrictMode field from DB type (diff)
downloaddedo-f9d0e860d710c36d85e4a920861442fdc8102b30.tar.gz
dedo-f9d0e860d710c36d85e4a920861442fdc8102b30.tar.xz
src/dedo.go: Remove AllocSize from DB type
Diffstat (limited to 'src/dedo.go')
-rw-r--r--src/dedo.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/dedo.go b/src/dedo.go
index 84c4cea..acf8ef1 100644
--- a/src/dedo.go
+++ b/src/dedo.go
@@ -125,10 +125,10 @@ type DB struct {
/// Do not change concurrently with calls to Batch.
MaxBatchDelay time.Duration
- /// AllocSize is the amount of space allocated when the database needs
+ /// allocSize is the amount of space allocated when the database needs
/// to create new pages. This is done to amortize the cost of
/// truncate() and fsync() when growing the data file.
- AllocSize int
+ allocSize int
path string
file *os.File
@@ -323,7 +323,8 @@ const (
/// Default values if not set in a DB instance.
DefaultMaxBatchSize int = 1000
DefaultMaxBatchDelay = 10 * time.Millisecond
- DefaultAllocSize = 16 * 1024 * 1024
+
+ allocGrowthSize = 16 * 1024 * 1024 // 16MiB
pageHeaderSize = int(unsafe.Offsetof(((*page)(nil)).ptr))
@@ -1513,7 +1514,6 @@ func newDB(path string, file *os.File, options OpenOptionsT) *DB {
return &DB{
MaxBatchSize: DefaultMaxBatchSize,
MaxBatchDelay: DefaultMaxBatchDelay,
- AllocSize: DefaultAllocSize,
opened: true,
path: path,
file: file,
@@ -2209,10 +2209,10 @@ func (db *DB) grow(sz int) error {
// If the data is smaller than the alloc size then only allocate what's
// needed. Once it goes over the allocation size then allocate in
// chunks.
- if db.datasz < db.AllocSize {
+ if db.datasz < allocGrowthSize {
sz = db.datasz
} else {
- sz += db.AllocSize
+ sz += allocGrowthSize
}
// Truncate and fsync to ensure file size metadata is flushed.