Skip to content

Commit efdf068

Browse files
committed
Avoid mmap for 32-bit architecture
1 parent b22e2aa commit efdf068

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

datastore.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"os"
78
"runtime"
89
"strings"
910
"sync"
@@ -107,8 +108,12 @@ func init() {
107108
// reading (in some tests).
108109
DefaultOptions.Options.ValueLogLoadingMode = options.FileIO
109110

110-
// Explicitly set this to mmap. This doesn't use much memory anyways.
111-
DefaultOptions.Options.TableLoadingMode = options.MemoryMap
111+
if os.Getenv("GOARCH") == "386" {
112+
DefaultOptions.Options.TableLoadingMode = options.FileIO
113+
} else {
114+
// Explicitly set this to mmap. This doesn't use much memory anyways.
115+
DefaultOptions.Options.TableLoadingMode = options.MemoryMap
116+
}
112117

113118
// Reduce this from 64MiB to 16MiB. That means badger will hold on to
114119
// 20MiB by default instead of 80MiB.

ds_test.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import (
55
"context"
66
"crypto/rand"
77
"fmt"
8-
"os"
98
"sort"
109
"testing"
1110
"time"
1211

13-
options "github.com/dgraph-io/badger/options"
1412
ds "github.com/ipfs/go-datastore"
1513
dsq "github.com/ipfs/go-datastore/query"
1614
dstest "github.com/ipfs/go-datastore/test"
@@ -634,11 +632,7 @@ func TestDiskUsage(t *testing.T) {
634632
addTestCases(t, d, testcases)
635633
d.Close()
636634

637-
dsOpts := DefaultOptions
638-
if os.Getenv("GOARCH") == "386" {
639-
dsOpts.Options.TableLoadingMode = options.FileIO
640-
}
641-
d, err = NewDatastore(path, &dsOpts)
635+
d, err = NewDatastore(path, nil)
642636
if err != nil {
643637
t.Fatal(err)
644638
}

0 commit comments

Comments
 (0)