mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
storage/backend: support MAP_POPULATE for unix
This adds build constraints in order to pass memory-map flags to bolt.Option. If backend package passes syscall.MAP_POPULATE flag, the boltdb does read-ahead which speeds up entire-database read, which then leads to faster storage Restore. Benchmark result shows for 4GB, it opens and loads 6x faster in SSD, and 12x faster in HDD. For 2GB, 1.6x faster with MAP_POPULATE in SSD.
This commit is contained in:
parent
185097ffaa
commit
7638423f85
@ -61,7 +61,7 @@ func New(path string, d time.Duration, limit int) Backend {
|
||||
}
|
||||
|
||||
func newBackend(path string, d time.Duration, limit int) *backend {
|
||||
db, err := bolt.Open(path, 0600, nil)
|
||||
db, err := bolt.Open(path, 0600, boltOpenOptions)
|
||||
if err != nil {
|
||||
log.Panicf("backend: cannot open database at %s (%v)", path, err)
|
||||
}
|
||||
|
19
storage/backend/boltoption_darwin.go
Normal file
19
storage/backend/boltoption_darwin.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package backend
|
||||
|
||||
import "github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
|
||||
|
||||
var boltOpenOptions *bolt.Options = nil
|
19
storage/backend/boltoption_freebsd.go
Normal file
19
storage/backend/boltoption_freebsd.go
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package backend
|
||||
|
||||
import "github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
|
||||
|
||||
var boltOpenOptions *bolt.Options = nil
|
31
storage/backend/boltoption_unix.go
Normal file
31
storage/backend/boltoption_unix.go
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// +build linux solaris
|
||||
|
||||
package backend
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
|
||||
)
|
||||
|
||||
// syscall.MAP_POPULATE on linux 2.6.23+ does sequential read-ahead
|
||||
// which can speed up entire-database read with boltdb. We want to
|
||||
// enable MAP_POPULATE for faster key-value store recovery in storage
|
||||
// package. If your kernel version is lower than 2.6.23
|
||||
// (https://github.com/torvalds/linux/releases/tag/v2.6.23), mmap might
|
||||
// silently ignore this flag. Please update your kernel to prevent this.
|
||||
var boltOpenOptions = &bolt.Options{MmapFlags: syscall.MAP_POPULATE}
|
21
storage/backend/boltoption_windows.go
Normal file
21
storage/backend/boltoption_windows.go
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2015 CoreOS, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package backend
|
||||
|
||||
import "github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
|
||||
|
||||
// TODO: support syscall.MAP_POPULATE in windows.
|
||||
// Need upstream patch from boltdb/bolt.
|
||||
var boltOpenOptions *bolt.Option = nil
|
Loading…
x
Reference in New Issue
Block a user