aboutsummaryrefslogtreecommitdiff
path: root/bolt_unix.go
diff options
context:
space:
mode:
authorXiang Li <xiangli.cs@gmail.com>2015-11-04 15:12:18 -0800
committerXiang Li <xiangli.cs@gmail.com>2015-11-06 09:39:17 -0800
commite67705ed6348675b7bae405ebeb37bb69b53a96d (patch)
tree896094dfe1466aa5a017424ee19a434dbf9f35cb /bolt_unix.go
parentMerge pull request #428 from lukechampine/patch-1 (diff)
downloaddedo-e67705ed6348675b7bae405ebeb37bb69b53a96d.tar.gz
dedo-e67705ed6348675b7bae405ebeb37bb69b53a96d.tar.xz
do not grow dbsize agressively
Only grow the database size when the high watermark increases. We also grows the database size a little bit aggressively to save a few ftruncates. I have tested this on various environments. The performance impact is ignorable with 16MB over allocation. Without over allocation, the performance might decrease 100% when each Tx.Commit needs a new page on a very slow disk (seek time dominates the total write).
Diffstat (limited to 'bolt_unix.go')
-rw-r--r--bolt_unix.go11
1 files changed, 0 insertions, 11 deletions
diff --git a/bolt_unix.go b/bolt_unix.go
index 6eef6b2..5a199c7 100644
--- a/bolt_unix.go
+++ b/bolt_unix.go
@@ -46,17 +46,6 @@ func funlock(f *os.File) error {
// mmap memory maps a DB's data file.
func mmap(db *DB, sz int) error {
- // Truncate and fsync to ensure file size metadata is flushed.
- // https://github.com/boltdb/bolt/issues/284
- if !db.NoGrowSync && !db.readOnly {
- if err := db.file.Truncate(int64(sz)); err != nil {
- return fmt.Errorf("file resize error: %s", err)
- }
- if err := db.file.Sync(); err != nil {
- return fmt.Errorf("file sync error: %s", err)
- }
- }
-
// Map the data file to memory.
b, err := syscall.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED)
if err != nil {