Skip to content

Conversation

@mattevans
Copy link
Member

Replace synchronous, per-block metrics collection with dedicated background goroutines that refresh heavy metrics every 15s. This removes ClickHouse queries from the hot path and reduces block-processing latency.

  • Remove updateBlockMetrics() from both structlog & structlog_agg
  • Add start/stopMetricsWorker() helpers and runMetricsWorker() loop
  • Keep only lightweight BlockHeight update in ProcessNextBlock
  • Introduce limiter cache in state.Manager to avoid repeated MAX() queries; refresh every 6 s via background goroutine
  • Update limiter query to use ORDER BY … LIMIT 1 for index usage
  • Add comprehensive tests for cache hit/miss, concurrent access, single-start guarantees and refresh behaviour

Replace synchronous, per-block metrics collection with dedicated
background goroutines that refresh heavy metrics every 15 s.
This removes costly ClickHouse queries from the hot path and
reduces block-processing latency.

- Remove updateBlockMetrics() from both structlog & structlog_agg
- Add start/stopMetricsWorker() helpers and runMetricsWorker() loop
- Keep only lightweight BlockHeight update in ProcessNextBlock
- Introduce limiter cache in state.Manager to avoid repeated
 MAX() queries; refresh every 6 s via background goroutine
- Update limiter query to use ORDER BY … LIMIT 1 for index usage
- Add comprehensive tests for cache hit/miss, concurrent access,
 single-start guarantees and refresh behaviour
@mattevans mattevans self-assigned this Jan 30, 2026
@mattevans mattevans requested a review from Savid as a code owner January 30, 2026 09:06
@mattevans mattevans merged commit f92bc27 into release/embed-mode-structlog-agg Jan 30, 2026
3 checks passed
@mattevans mattevans deleted the refactor/next-block-hot-path branch January 30, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants