Skip to content

Refactor: unify and fix session statistics counters#1510

Merged
Sakoram merged 5 commits intomainfrom
refactor/unify-session-stats-mixins
Apr 15, 2026
Merged

Refactor: unify and fix session statistics counters#1510
Sakoram merged 5 commits intomainfrom
refactor/unify-session-stats-mixins

Conversation

@Sakoram
Copy link
Copy Markdown
Collaborator

@Sakoram Sakoram commented Apr 13, 2026

Unify RX/TX session statistics across all session types for consistency and thread safety.

  • Type fixes & cleanup: fix int→uint64_t mismatches, remove dead fields, populate err_packets for audio/anc/fmd
  • Unified loss counter: add stat_pkts_unrecovered to common st_rx_user_stats (replaces stat_frames_pks_missed)
  • Move duplicated fields to common structs: stat_pkts_redundant (RX), stat_epoch_mismatch/stat_recoverable_error/stat_unrecoverable_error (TX)
  • Consistent OOO counting: out_of_order_packets now counts missing packets (+= gap_size) not gap events (++), so stat_pkts_unrecovered <= stat_pkts_out_of_order holds
  • Thread-safe stats API: get/reset_session_stats now acquire per-session spinlock (negligible data-path impact)
  • Docs: add doc/stats_guide.md with pipeline diagram, counter interpretation, and troubleshooting

Fields moved from session-specific structs to common are removed from st20/st30/st40/st41 API headers — see commit 6ef76f2 for the full list.

@Sakoram Sakoram marked this pull request as ready for review April 14, 2026 06:34
Copy link
Copy Markdown
Collaborator

@DawidWesierski4 DawidWesierski4 left a comment

Choose a reason for hiding this comment

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

Please make sure noctx integration tests are not affected as they will be run in nightly

also please include information about Reset not being thread safe

@Sakoram Sakoram changed the title Fix: stats type mismatches, dead fields, and redundant counters Refactor: unify and fix session statistics counters Apr 15, 2026
@Sakoram
Copy link
Copy Markdown
Collaborator Author

Sakoram commented Apr 15, 2026

Please make sure noctx integration tests are not affected as they will be run in nightly

also please include information about Reset not being thread safe

All noctx tests passed, I made reset thread safe.

@Sakoram Sakoram force-pushed the refactor/unify-session-stats-mixins branch from 1669b2b to 1d26bb5 Compare April 15, 2026 08:30
Sakoram added 5 commits April 15, 2026 11:12
- Fix int/uint32_t -> uint64_t for stat fields in st40_rx and st41_rx
- Remove 9 wrong-domain RX fields from st41_tx_user_stats (never set)
- Remove stale stat_last_time copy in TX fastmetadata stat dump
- Remove redundant stat_pkts_out_of_order_per_port internal counter
  from all 4 RX session types (already tracked via port_user_stats)
- Add per-port out-of-order breakdown for RX video sessions
- Use snapshot-based deltas for per-port OOO logging in all sessions
- Fix TX video stat_pkts_burst: print before reset (was silently zeroed)
- Fix format specifiers in RX fastmetadata stat dump to match uint64_t
- Add stat_pkts_unrecovered to st_rx_user_stats: unified post-redundancy
  loss counter for all session types (video/audio/anc/fmd)
- Audio/anc/fmd: count actual missing packets per RTP sequence gap
  instead of gap events
- Video: feed estimated missing packets from corrupted frames into
  the unified counter
- Remove stat_frames_pks_missed from st20_rx_user_stats (superseded
  by stat_pkts_unrecovered in common stats)
- Populate err_packets for audio/anc/fmd RX (was always 0)
- Add stat_pkts_out_of_order++ at per-port OOO sites for audio/anc/fmd
  to match video behavior (aggregate = sum of per-port counters)
- Improve doxygen: pre/post-redundancy annotations on st_rx_port_stats
  and st_rx_user_stats, mark dead ST41 interlace fields
Pipeline diagram, OOO/loss counter interpretation with scenario table,
cross-session differences, and troubleshooting reference.
Field descriptions are kept in header file doxygen comments only.
RX: move stat_pkts_redundant to st_rx_user_stats (was duplicated in
st30/st40/st41 as stat_pkts_redundant, and in st20 as
stat_pkts_redundant_dropped with same semantics).

TX: move stat_epoch_mismatch, stat_recoverable_error, and
stat_unrecoverable_error to st_tx_user_stats (were duplicated across
st20/st30/st40/st41 session-specific structs).
Wrap all 16 get/reset_session_stats implementations with the existing
per-session mgr->mutex[idx] spinlock to prevent races with the data-path
tasklet. Add @note Thread-safe to all 28 doxygen blocks across 7 headers.

Change out_of_order_packets and stat_pkts_out_of_order from counting gap
events (++) to counting actual missing packets (+= gap_size), consistent
with stat_pkts_unrecovered. The invariant
stat_pkts_unrecovered <= stat_pkts_out_of_order now holds.

Update doxygen in st_api.h and stats_guide.md accordingly.
@Sakoram Sakoram force-pushed the refactor/unify-session-stats-mixins branch from 1d26bb5 to 820bed0 Compare April 15, 2026 09:12
@Sakoram Sakoram enabled auto-merge (rebase) April 15, 2026 10:29
@Sakoram Sakoram merged commit f0aafd7 into main Apr 15, 2026
21 checks passed
@Sakoram Sakoram deleted the refactor/unify-session-stats-mixins branch April 15, 2026 11:51
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