Skip to content

relay: walk cached track stats in place - #627

Merged
afrind merged 1 commit into
mainfrom
relay/walk-cached-track-stats
Aug 26, 2026
Merged

relay: walk cached track stats in place#627
afrind merged 1 commit into
mainfrom
relay/walk-cached-track-stats

Conversation

@afrind

@afrind afrind commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

/state's cache section went through MoqxCache::getTrackStats(), which copies every track name and allocates a group vector per track, so the walk could serialize the snapshot and then drop it.

forEachTrackStats hands the visitor a TrackStatsView borrowing the cache's own data, reusing one group vector across tracks; returning false stops the walk. The visitor's cache callback splits to match:

  visitor.onCacheBegin(bytes, now);
  cache_->forEachTrackStats([&](const auto& t) { return visitor.onCacheTrack(t); });
  visitor.onCacheEnd();

getTrackStats() stays for callers that want a snapshot, now implemented on top of the walk -- so MoqxCacheTest covers both. Tracks are visited in the same order, so the JSON is unchanged.


This change is Reviewable

@akash-a-n akash-a-n left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@akash-a-n reviewed 5 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on afrind).

/state's cache section went through MoqxCache::getTrackStats(), which copies
every track name and allocates a group vector per track, so the walk could
serialize the snapshot and then drop it.

forEachTrackStats hands the visitor a TrackStatsView borrowing the cache's own
data, reusing one group vector across tracks; returning false stops the walk.
The visitor's cache callback splits to match:

  visitor.onCacheBegin(bytes, now);
  cache_->forEachTrackStats([&](const auto& t) { return visitor.onCacheTrack(t); });
  visitor.onCacheEnd();

getTrackStats() stays for callers that want a snapshot, now implemented on top
of the walk -- so MoqxCacheTest covers both. Tracks are visited in the same
order, so the JSON is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@afrind
afrind force-pushed the relay/walk-cached-track-stats branch from 3d67250 to 2260922 Compare August 26, 2026 16:07
@afrind
afrind merged commit ff2454c into main Aug 26, 2026
8 checks passed
@afrind
afrind deleted the relay/walk-cached-track-stats branch August 26, 2026 17:42
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.

2 participants