Skip to content

Commit

Permalink
Always use file IO with 32-bit arch
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Feb 17, 2025
1 parent efdf068 commit 8afd4ff
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,8 @@ func init() {
// reading (in some tests).
DefaultOptions.Options.ValueLogLoadingMode = options.FileIO

if os.Getenv("GOARCH") == "386" {
DefaultOptions.Options.TableLoadingMode = options.FileIO
} else {
// Explicitly set this to mmap. This doesn't use much memory anyways.
DefaultOptions.Options.TableLoadingMode = options.MemoryMap
}
// Explicitly set this to mmap. This doesn't use much memory anyways.
DefaultOptions.Options.TableLoadingMode = options.MemoryMap

// Reduce this from 64MiB to 16MiB. That means badger will hold on to
// 20MiB by default instead of 80MiB.
Expand All @@ -133,22 +129,26 @@ var _ ds.Batching = (*Datastore)(nil)
// NewDatastore creates a new badger datastore.
//
// DO NOT set the Dir and/or ValuePath fields of opt, they will be set for you.
func NewDatastore(path string, options *Options) (*Datastore, error) {
func NewDatastore(path string, opts *Options) (*Datastore, error) {
// Copy the options because we modify them.
var opt badger.Options
var gcDiscardRatio float64
var gcSleep time.Duration
var gcInterval time.Duration
if options == nil {
if opts == nil {
opt = badger.DefaultOptions("")
gcDiscardRatio = DefaultOptions.GcDiscardRatio
gcSleep = DefaultOptions.GcSleep
gcInterval = DefaultOptions.GcInterval
} else {
opt = options.Options
gcDiscardRatio = options.GcDiscardRatio
gcSleep = options.GcSleep
gcInterval = options.GcInterval
opt = opts.Options
gcDiscardRatio = opts.GcDiscardRatio
gcSleep = opts.GcSleep
gcInterval = opts.GcInterval
}

if os.Getenv("GOARCH") == "386" {
opt.TableLoadingMode = options.FileIO
}

if gcSleep <= 0 {
Expand Down

0 comments on commit 8afd4ff

Please # to comment.