mirror of
https://github.com/status-im/status-go.git
synced 2026-08-31 00:51:12 +00:00
Part of https://github.com/status-im/status-app/issues/21462 - Open existing app and wallet SQLCipher databases concurrently, while preserving sequential initialization for new or legacy databases. - Speed up account selection by preloading the profile keypair and decrypting only the chat private key instead of the full extended key. - Defer token manager startup until after login completes and run it asynchronously outside the critical startup path. - Load cached leaderboard market data asynchronously, waiting only when the data is accessed or the service stops. Before: about 2.15 s for the backend login request After: about 0.47–0.50 s Improvement: roughly 1.65–1.70 s saved Relative reduction: about 77–78% Speed multiplier: approximately 4.3–4.5× faster
46 lines
738 B
Go
46 lines
738 B
Go
package sqlite
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestOpenDBConcurrently(t *testing.T) {
|
|
const workers = 32
|
|
|
|
start := make(chan struct{})
|
|
errors := make(chan error, workers)
|
|
var waitGroup sync.WaitGroup
|
|
waitGroup.Add(workers)
|
|
|
|
for range workers {
|
|
go func() {
|
|
defer waitGroup.Done()
|
|
defer func() {
|
|
if recovered := recover(); recovered != nil {
|
|
errors <- fmt.Errorf("OpenDB panicked: %v", recovered)
|
|
}
|
|
}()
|
|
|
|
<-start
|
|
db, err := OpenDB(InMemoryPath, "password", 2)
|
|
if err != nil {
|
|
errors <- err
|
|
return
|
|
}
|
|
errors <- db.Close()
|
|
}()
|
|
}
|
|
|
|
close(start)
|
|
waitGroup.Wait()
|
|
close(errors)
|
|
|
|
for err := range errors {
|
|
require.NoError(t, err)
|
|
}
|
|
}
|