Skip to content

Conversation

@gefjon
Copy link
Contributor

@gefjon gefjon commented Sep 24, 2025

Description of Changes

Inspired by a question @Shubham8287 asked me: how long does it take to replay real production databases, e.g. a BitCraft region module? I did not have a good answer, and didn't know how I could get an answer.

Add 5 new metrics:

  • replay_total_time_seconds(db: Identity), total time to read and restore snapshot and replay commitlog.
  • replay_snapshot_read_time_seconds(db: Identity), time to read snapshot from disk.
  • replay_snapshot_restore_time_seconds(db: Identity), time to restore snapshot once it's already in memory.
  • replay_commitlog_time_seconds(db: Identity), time to replay commitlog once snapshot is restored.
  • replay_commitlog_num_commits(db: Identity), number of commits visited during commitlog replay, i.e. the length of the suffix after the most recent usable snapshot.

All of these are Gauges (or IntGauge for the num_commits metric), as we expect observations to be very infrequent
(approx. once per label value per SpacetimeDB process).

API and ABI breaking changes

N/a

Expected complexity level and risk

1

Testing

I remain unsure how to test metrics. This won't break anything, though, so I'm not worried.

Add 5 new metrics:

- `replay_total_time_seconds(db: Identity)`,
  total time to read and restore snapshot and replay commitlog.
- `replay_snapshot_read_time_seconds(db: Identity)`, time to read snapshot from disk.
- `replay_snapshot_restore_time_seconds(db: Identity)`,
  time to restore snapshot once it's already in memory.
- `replay_commitlog_time_seconds(db: Identity)`,
  time to replay commitlog once snapshot is restored.
- `replay_commitlog_num_commits(db: Identity)`,
  number of commits visited during commitlog replay,
  i.e. the length of the suffix after the most recent usable snapshot.

All of these are `Gauge`s (or `IntGauge` for the `num_commits` metric),
as we expect observations to be very infrequent
(approx. once per label value per SpacetimeDB process).
Copy link
Contributor

@Shubham8287 Shubham8287 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@gefjon gefjon added this pull request to the merge queue Sep 24, 2025
Merged via the queue into master with commit 4521487 Sep 24, 2025
26 of 27 checks passed
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