aboutsummaryrefslogtreecommitdiff
path: root/tx.go
diff options
context:
space:
mode:
Diffstat (limited to 'tx.go')
-rw-r--r--tx.go16
1 files changed, 11 insertions, 5 deletions
diff --git a/tx.go b/tx.go
index 759913d..bc2842f 100644
--- a/tx.go
+++ b/tx.go
@@ -141,7 +141,9 @@ func (tx *Tx) Commit() error {
// Rebalance nodes which have had deletions.
var startTime = time.Now()
tx.root.rebalance()
- tx.stats.RebalanceTime += time.Since(startTime)
+ if tx.stats.Rebalance > 0 {
+ tx.stats.RebalanceTime += time.Since(startTime)
+ }
// spill data onto dirty pages.
startTime = time.Now()
@@ -423,8 +425,10 @@ func (tx *Tx) write() error {
// Update statistics.
tx.stats.Write++
}
- if err := fdatasync(tx.db.file); err != nil {
- return err
+ if !tx.db.NoSync {
+ if err := fdatasync(tx.db.file); err != nil {
+ return err
+ }
}
// Clear out page cache.
@@ -444,8 +448,10 @@ func (tx *Tx) writeMeta() error {
if _, err := tx.db.ops.writeAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil {
return err
}
- if err := fdatasync(tx.db.file); err != nil {
- return err
+ if !tx.db.NoSync {
+ if err := fdatasync(tx.db.file); err != nil {
+ return err
+ }
}
// Update statistics.