Skip to content

Commit 0266a9b

Browse files
committed
force open LevelDB in parallel
1 parent 22f45ce commit 0266a9b

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

go/libkb/globals.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,10 +651,14 @@ func (g *GlobalContext) configureDiskCachesLocked() error {
651651
g.LocalDb = NewJSONLocalDb(NewLevelDb(g, g.Env.GetDbFilename))
652652
g.LocalChatDb = NewJSONLocalDb(NewLevelDb(g, g.Env.GetChatDbFilename))
653653

654-
epick := FirstErrorPicker{}
655-
epick.Push(g.LocalDb.Open())
656-
epick.Push(g.LocalChatDb.Open())
657-
return epick.Error()
654+
// Pre-warm both DBs concurrently. Open() is a no-op (lazy open via
655+
// sync.Once), so kick off ForceOpen in goroutines instead. Any
656+
// subsequent DB operation will block on sync.Once until its open
657+
// completes — no further synchronization needed here.
658+
go func() { _ = g.LocalDb.ForceOpen() }()
659+
go func() { _ = g.LocalChatDb.ForceOpen() }()
660+
661+
return nil
658662
}
659663

660664
func (g *GlobalContext) ConfigureMerkleClient() error {

go/service/main.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,6 @@ func (d *Service) Run() (err error) {
303303
return
304304
}
305305

306-
if err = d.G().LocalDb.ForceOpen(); err != nil {
307-
return err
308-
}
309-
if err = d.G().LocalChatDb.ForceOpen(); err != nil {
310-
return err
311-
}
312-
313306
var l net.Listener
314307
if l, err = d.ConfigRPCServer(); err != nil {
315308
return err

0 commit comments

Comments
 (0)