diff --git a/storage/backend/backend.go b/storage/backend/backend.go index b8a2f2ad4..608752452 100644 --- a/storage/backend/backend.go +++ b/storage/backend/backend.go @@ -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) } diff --git a/storage/backend/boltoption_darwin.go b/storage/backend/boltoption_darwin.go new file mode 100644 index 000000000..856febdf0 --- /dev/null +++ b/storage/backend/boltoption_darwin.go @@ -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 diff --git a/storage/backend/boltoption_freebsd.go b/storage/backend/boltoption_freebsd.go new file mode 100644 index 000000000..856febdf0 --- /dev/null +++ b/storage/backend/boltoption_freebsd.go @@ -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 diff --git a/storage/backend/boltoption_unix.go b/storage/backend/boltoption_unix.go new file mode 100644 index 000000000..bd676a524 --- /dev/null +++ b/storage/backend/boltoption_unix.go @@ -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} diff --git a/storage/backend/boltoption_windows.go b/storage/backend/boltoption_windows.go new file mode 100644 index 000000000..1b9ce9471 --- /dev/null +++ b/storage/backend/boltoption_windows.go @@ -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