diff options
author | EuAndreh <eu@euandre.org> | 2024-12-30 15:39:09 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-12-30 15:43:40 -0300 |
commit | 9dee89f4909ccf23cbcc11665364cd776625db03 (patch) | |
tree | a11194dcfb18582f90a2d5ffcba37428ca9cf173 | |
parent | tests/dedo.go: Normalize tests (diff) | |
download | dedo-9dee89f4909ccf23cbcc11665364cd776625db03.tar.gz dedo-9dee89f4909ccf23cbcc11665364cd776625db03.tar.xz |
src/dedo.go: Remove DB.NoSync option
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | src/dedo.go | 41 |
2 files changed, 6 insertions, 38 deletions
@@ -758,8 +758,7 @@ lock-free MVCC using a single writer and multiple readers. The two projects have somewhat diverged. LMDB heavily focuses on raw performance while Bolt has focused on simplicity and ease of use. For example, LMDB allows several unsafe actions such as direct writes for the sake of performance. Bolt -opts to disallow actions which can leave the database in a corrupted state. The -only exception to this in Bolt is `DB.NoSync`. +opts to disallow actions which can leave the database in a corrupted state. There are also a few differences in API. LMDB requires a maximum mmap size when opening an `mdb_env` whereas Bolt will handle incremental mmap resizing diff --git a/src/dedo.go b/src/dedo.go index dcc4956..437d04f 100644 --- a/src/dedo.go +++ b/src/dedo.go @@ -1294,12 +1294,6 @@ const version = 2 // Represents a marker value to indicate that a file is a Bolt DB. const magic uint32 = 0xED0CDAED -// IgnoreNoSync specifies whether the NoSync field of a DB is ignored when -// syncing changes to a file. This is required as some operating systems, -// such as OpenBSD, do not have a unified buffer cache (UBC) and writes -// must be synchronized using the msync(2) syscall. -const IgnoreNoSync = runtime.GOOS == "openbsd" - // Default values if not set in a DB instance. const ( DefaultMaxBatchSize int = 1000 @@ -1320,18 +1314,6 @@ type DB struct { // debugging purposes. StrictMode bool - // Setting the NoSync flag will cause the database to skip fsync() - // calls after each commit. This can be useful when bulk loading data - // into a database and you can restart the bulk load in the event of - // a system failure or database corruption. Do not set this flag for - // normal use. - // - // If the package global IgnoreNoSync constant is true, this value is - // ignored. See the comment on that constant for more details. - // - // THIS IS UNSAFE. PLEASE USE WITH CAUTION. - NoSync bool - // When true, skips the truncate call when growing the database. // Setting this to true is only safe on non-ext3/ext4 systems. // Skipping truncation avoids preallocation of hard drive space and @@ -2039,12 +2021,6 @@ func safelyCall(fn func(*Tx) error, tx *Tx) (err error) { return fn(tx) } -// Sync executes fdatasync() against the database file handle. -// -// This is not necessary under normal operation, however, if you use NoSync -// then it allows you to force the database file to sync against the disk. -func (db *DB) Sync() error { return fdatasync(db) } - // Stats retrieves ongoing performance stats for the database. // This is only updated when a transaction closes. func (db *DB) Stats() Stats { @@ -3954,11 +3930,8 @@ func (tx *Tx) write() error { } } - // Ignore file sync if flag is set on DB. - if !tx.db.NoSync || IgnoreNoSync { - if err := fdatasync(tx.db); err != nil { - return err - } + if err := fdatasync(tx.db); err != nil { + return err } // Put small pages back to page pool. @@ -3992,10 +3965,9 @@ func (tx *Tx) writeMeta() error { if _, err := tx.db.ops.writeAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil { return err } - if !tx.db.NoSync || IgnoreNoSync { - if err := fdatasync(tx.db); err != nil { - return err - } + + if err := fdatasync(tx.db); err != nil { + return err } // Update statistics. @@ -5020,7 +4992,6 @@ func (cmd *BenchCommand) Run(args ...string) error { if err != nil { return err } - db.NoSync = options.NoSync defer db.Close() // Write to the database. @@ -5058,7 +5029,6 @@ func (cmd *BenchCommand) ParseFlags(args []string) (*BenchOptions, error) { fs.StringVar(&options.MemProfile, "memprofile", "", "") fs.StringVar(&options.BlockProfile, "blockprofile", "", "") fs.Float64Var(&options.FillPercent, "fill-percent", DefaultFillPercent, "") - fs.BoolVar(&options.NoSync, "no-sync", false, "") fs.BoolVar(&options.Work, "work", false, "") fs.StringVar(&options.Path, "path", "", "") fs.SetOutput(cmd.Stderr) @@ -5388,7 +5358,6 @@ type BenchOptions struct { BlockProfile string StatsInterval time.Duration FillPercent float64 - NoSync bool Work bool Path string } |