aboutsummaryrefslogtreecommitdiff
path: root/db.go
diff options
context:
space:
mode:
authorGyu-Ho Lee <gyuhox@gmail.com>2015-11-08 17:30:52 -0800
committerGyu-Ho Lee <gyuhox@gmail.com>2015-11-08 18:07:10 -0800
commitd97579c39936dad5028a38ce05e4700bf91f82b2 (patch)
tree240e530df2fb79b1be6cddf04aeaea2cd8825ad4 /db.go
parentMerge branch 'xiang90-tx_write' (diff)
downloaddedo-d97579c39936dad5028a38ce05e4700bf91f82b2.tar.gz
dedo-d97579c39936dad5028a38ce05e4700bf91f82b2.tar.xz
Add MmapFlags option for MAP_POPULATE (unix)
This adds MmapFlags to DB.Options in case we need syscall.MAP_POPULATE flag in Linux 2.6.23+ to do the sequential read-ahead, as discussed in [1]. --- [1]: https://github.com/coreos/etcd/issues/3786
Diffstat (limited to 'db.go')
-rw-r--r--db.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/db.go b/db.go
index d39c4aa..4ff07ae 100644
--- a/db.go
+++ b/db.go
@@ -63,6 +63,10 @@ type DB struct {
// https://github.com/boltdb/bolt/issues/284
NoGrowSync bool
+ // If you want to read the entire database fast, you can set MmapFlag to
+ // syscall.MAP_POPULATE on Linux 2.6.23+ for sequential read-ahead.
+ MmapFlags int
+
// MaxBatchSize is the maximum size of a batch. Default value is
// copied from DefaultMaxBatchSize in Open.
//
@@ -136,6 +140,7 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
options = DefaultOptions
}
db.NoGrowSync = options.NoGrowSync
+ db.MmapFlags = options.MmapFlags
// Set default values for later DB operations.
db.MaxBatchSize = DefaultMaxBatchSize
@@ -672,6 +677,9 @@ type Options struct {
// Open database in read-only mode. Uses flock(..., LOCK_SH |LOCK_NB) to
// grab a shared lock (UNIX).
ReadOnly bool
+
+ // Sets the DB.MmapFlags flag before memory mapping the file.
+ MmapFlags int
}
// DefaultOptions represent the options used if nil options are passed into Open().