Skip to content

Commit

Permalink
Fix arm compilation of backend.go
Browse files Browse the repository at this point in the history
  • Loading branch information
luxas committed Mar 8, 2016
1 parent f74d732 commit daba39f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
5 changes: 0 additions & 5 deletions storage/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ var (
defaultBatchInterval = 100 * time.Millisecond

defragLimit = 10000

// InitialMmapSize is the initial size of the mmapped region. Setting this larger than
// the potential max db size can prevent writer from blocking reader.
// This only works for linux.
InitialMmapSize = 10 * 1024 * 1024 * 1024
)

type Backend interface {
Expand Down
45 changes: 45 additions & 0 deletions storage/backend/boltoption_arm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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,arm

package backend

import (
"syscall"
"math"

"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
)

var (
// InitialMmapSize is the initial size of the mmapped region. Setting this larger than
// the potential max db size can prevent writer from blocking reader.
// This only works for linux and only on arm 32-bit
// This sets InitialMmapSize to 2GB, or (2 * 1024 * 1024 * 1024) - 1
InitialMmapSize = math.MaxInt32
)


// 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,
InitialMmapSize: InitialMmapSize,
}
10 changes: 9 additions & 1 deletion storage/backend/boltoption_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// +build linux

// +build linux,!arm

package backend

Expand All @@ -22,6 +23,13 @@ import (
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/boltdb/bolt"
)

var (
// InitialMmapSize is the initial size of the mmapped region. Setting this larger than
// the potential max db size can prevent writer from blocking reader.
// This only works for linux.
InitialMmapSize = 10 * 1024 * 1024 * 1024
)

// 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
Expand Down

0 comments on commit daba39f

Please sign in to comment.