mirror of
https://github.com/luxfi/explorer.git
synced 2026-09-24 00:25:12 +00:00
Warm one chain at a time, the front page's first
Every chain this process serves shares one disk. Warming them together made each finish late and made a caller arriving during startup wait behind the contention rather than behind its own chain's scan. In turn, each finishes as fast as the disk allows, and the chain the front page asks about is ready first.
This commit is contained in:
@@ -197,12 +197,23 @@ func trailing(points []statsPoint, days int) []statsPoint {
|
||||
|
||||
// Warm computes every configured chain's aggregate so the first caller after a
|
||||
// start reads it from memory instead of waiting for the scan.
|
||||
// One chain at a time, and the default one first. Every chain this process
|
||||
// serves would otherwise scan its whole index at the same moment, and they
|
||||
// share one disk: run together they all finish late, and a caller that arrives
|
||||
// meanwhile waits behind its own chain's share of the contention. Run in turn,
|
||||
// each finishes as fast as the disk allows, and the chain the front page asks
|
||||
// about is ready first.
|
||||
func (s *StatsService) Warm() {
|
||||
for _, ch := range s.cfg.Chains {
|
||||
if ch.Slug == "" {
|
||||
continue
|
||||
if ch.Default && ch.Slug != "" {
|
||||
s.numbers(ch.Slug)
|
||||
break
|
||||
}
|
||||
}
|
||||
for _, ch := range s.cfg.Chains {
|
||||
if ch.Slug != "" && !ch.Default {
|
||||
s.numbers(ch.Slug)
|
||||
}
|
||||
go s.numbers(ch.Slug)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user