-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add MmapFlags option for MAP_POPULATE (unix) #455
Conversation
@gyuho A more meaningful comparison is to compare readahead enabled with cached read. |
@@ -63,6 +63,9 @@ type DB struct { | |||
// https://github.com/boltdb/bolt/issues/284 | |||
NoGrowSync bool | |||
|
|||
// When true, Linux 2.6.23+ sets MAP_POPULATE for sequential read-ahead. | |||
MmapFlags bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be a bool but a int. So people can set the flag directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then in the comment we can mention that if you want to read entire database fast, you can set MmapFlag to syscall.MAP_POPULATE
on linux.
Overall, lgtm. Just some minor clean up with the |
Thanks! I will clean things up tonight. |
@benbjohnson Just updated as you suggest, and ran the same performance tests, for sample 2GB data:
Thanks, |
@@ -63,6 +63,11 @@ 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. | |||
// https://github.com/coreos/etcd/issues/3786 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the issue reference from etcd. It does not make a lot of sense to others.
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]: etcd-io/etcd#3786
@xiang90 Just removed it from the |
👍 lgtm, thanks for all the tweaks and the benchmarks. |
Add MmapFlags option for MAP_POPULATE (unix)
Thanks @benbjohnson ! |
/cc @xiang90
This adds MmapFlags to set syscall.MAP_POPULATE in Linux 2.6.23+.
If true, it would do the sequential read-ahead, as discussed in [1].
Xiang helped me on this PR. I benchmarked the READ performance and with
MAP_POPULATE
flag,its read performance increased. I did:
echo "echo 1 > /proc/sys/vm/drop_caches" | sudo sh
MAP_POPULATE
and compare two results [2].Results - SSD, Ubuntu, Intel(R) Core(TM) i7-4910MQ CPU @ 2.90GHz, go version go1.5.1 linux/amd64, Linux kernel version: 3.16.0-52-generic
For 2GB, read takes 8 seconds without
MAP_POPULATE
, 4 seconds WITHMAP_POPULATE
.- HDD, 1 vCPU, 3.75 GB Memory, Google Cloud, Intel(R) Xeon(R) CPU @ 2.30GHz, go version go1.5.1 linux/amd64, Linux kernel version: 3.16.0-0.bpo.4-amd64
For 2GB, read takes 2 minutes 10 seconds seconds without
MAP_POPULATE
, 8 seconds WITHMAP_POPULATE
.And I added `MAP_POPULATE` and WITHOUT cleaning up the page cache in a separate machine. This takes about the same as the first test case where we cleaned up page cache.
[1]:
etcd-io/etcd#3786
[2]: