all repos — searchix @ 843de71ca2678f20f71a0fe76082611f5f748326

Search engine for NixOS, nix-darwin, home-manager and NUR users

perf: tune storage backend

Alan Pearce
commit

843de71ca2678f20f71a0fe76082611f5f748326

parent

abef2e5b0db37c771464469c3f83890b4cc0a297

1 file changed, 12 insertions(+), 4 deletions(-)

changed files
M internal/storage/store.gointernal/storage/store.go
@@ -20,9 +20,10 @@
var BatchSize = 10000 type Options struct { - Replace bool - Root *file.Root - Logger *log.Logger + Replace bool + LowMemory bool + Root *file.Root + Logger *log.Logger } type Store struct {
@@ -53,11 +54,18 @@ path := opts.Root.JoinPath(filename)
bb, err := storm.Open(path, storm.Codec(gob.Codec), storm.BoltOptions(0o600, &bbolt.Options{ - Timeout: 1 * time.Second, + FreelistType: bbolt.FreelistMapType, + NoFreelistSync: true, + NoGrowSync: true, + Timeout: 1 * time.Second, }), ) if err != nil { return nil, fault.Wrap(err, fmsg.With("failed to open database")) + } + + if !opts.LowMemory { + bb.Bolt.AllocSize = 100 * 1024 * 1024 } return &Store{