config_linux.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright 2015 The etcd Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package backend
  15. import (
  16. "syscall"
  17. bolt "go.etcd.io/bbolt"
  18. )
  19. // syscall.MAP_POPULATE on linux 2.6.23+ does sequential read-ahead
  20. // which can speed up entire-database read with boltdb. We want to
  21. // enable MAP_POPULATE for faster key-value store recovery in storage
  22. // package. If your kernel version is lower than 2.6.23
  23. // (https://github.com/torvalds/linux/releases/tag/v2.6.23), mmap might
  24. // silently ignore this flag. Please update your kernel to prevent this.
  25. var boltOpenOptions = &bolt.Options{
  26. MmapFlags: syscall.MAP_POPULATE,
  27. NoFreelistSync: true,
  28. }
  29. func (bcfg *BackendConfig) mmapSize() int { return int(bcfg.MmapSize) }