diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2015-11-12 08:10:49 -0700 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2015-11-12 08:10:49 -0700 |
commit | 0b00effdd7a8270ebd91c24297e51643e370dd52 (patch) | |
tree | a70349058cbdb731d702c02ef89627d2e5c7b40b /db.go | |
parent | Merge pull request #452 from benbjohnson/empty-seek (diff) | |
parent | Add MmapFlags option for MAP_POPULATE (unix) (diff) | |
download | dedo-0b00effdd7a8270ebd91c24297e51643e370dd52.tar.gz dedo-0b00effdd7a8270ebd91c24297e51643e370dd52.tar.xz |
Merge pull request #455 from gyuho/boltdb_unix_map_populate
Add MmapFlags option for MAP_POPULATE (unix)
Diffstat (limited to 'db.go')
-rw-r--r-- | db.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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(). |