Add metrics tracking time to restore a database from disk #3285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 (orIntGaugefor thenum_commitsmetric), 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.