Skip to content

Add global worker statistics param (QUIC_PARAM_GLOBAL_WORKER_STATISTICS)#6115

Draft
guhetier wants to merge 5 commits into
mainfrom
guhetier/worker_statistics_copilot
Draft

Add global worker statistics param (QUIC_PARAM_GLOBAL_WORKER_STATISTICS)#6115
guhetier wants to merge 5 commits into
mainfrom
guhetier/worker_statistics_copilot

Conversation

@guhetier

@guhetier guhetier commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Description

Add per-worker statistics accessible via MsQuic->GetParam(NULL, QUIC_PARAM_GLOBAL_WORKER_STATISTICS, ...):

  • QUIC_WORKER_STATISTICS struct: IdealProcessor, CumulativeActiveTimeUs, CumulativeWallTimeUs per CXPLAT worker
  • QUIC_WORKER_STATISTICS_LIST header with WorkerCount and WorkerStatsSize for forward-compatible stride-based iteration
  • Active time tracked at actual idle points (CxPlatEventQDequeue wait and CxPlatSchedulerYield), not Running flag transitions
  • Wall time measured from thread start, not worker allocation
  • Best-effort snapshot reads (no locks needed for diagnostics)

Preview-guarded in public header (QUIC_API_ENABLE_PREVIEW_FEATURES).

Testing

Tests to be added in a follow-up commit.

Documentation

New public API structs and param documented in msquic.h comments.

Comment thread src/core/library.c Fixed
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.32258% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.45%. Comparing base (51d449b) to head (96de8bf).

Files with missing lines Patch % Lines
src/core/library.c 90.32% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6115      +/-   ##
==========================================
- Coverage   86.15%   85.45%   -0.71%     
==========================================
  Files          60       60              
  Lines       18857    18888      +31     
==========================================
- Hits        16247    16141     -106     
- Misses       2610     2747     +137     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new preview global parameter, QUIC_PARAM_GLOBAL_WORKER_STATISTICS, to expose per-worker timing statistics (active vs wall time) from the library’s worker pool via MsQuic->GetParam(NULL, ...). This fits into MsQuic’s diagnostics/observability surface alongside existing global perf counters and other global params.

Changes:

  • Introduces new preview public structs QUIC_WORKER_STATISTICS and QUIC_WORKER_STATISTICS_LIST, plus the new global param ID in msquic.h.
  • Tracks worker active time at idle points (event-queue waits and scheduler yields) and adds a platform worker-pool API to snapshot per-worker stats.
  • Adds parameter-validation tests (user + kernel test harness registration) for querying/validating the new statistics.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/test/MsQuicTests.h Adds new test declarations for worker statistics.
src/test/lib/ApiTest.cpp Implements new tests to query and validate worker statistics snapshots.
src/test/bin/winkernel/control.cpp Registers the new tests in the kernel-mode test driver dispatcher.
src/test/bin/quic_gtest.cpp Adds new gtest cases to invoke the new worker statistics tests.
src/platform/platform_worker.c Adds per-worker timing accumulation and implements CxPlatWorkerPoolGetStatistics.
src/inc/quic_platform.h Declares CxPlatWorkerPoolGetStatistics for worker-pool snapshots.
src/inc/msquic.h Adds preview structs and the new QUIC_PARAM_GLOBAL_WORKER_STATISTICS global param constant.
src/core/library.c Implements QUIC_PARAM_GLOBAL_WORKER_STATISTICS in global param dispatch.

Comment thread src/test/MsQuicTests.h
Comment thread src/test/lib/ApiTest.cpp
Comment thread src/inc/msquic.h Outdated
Comment on lines +379 to +382
uint16_t IdealProcessor; // CPU the partition is affinitized to
uint8_t Reserved[6]; // Padding for alignment
uint64_t CumulativeActiveTimeUs; // total time IsActive == TRUE
uint64_t CumulativeWallTimeUs; // wall time since worker was created
Comment thread src/platform/platform_worker.c Outdated
Comment on lines +895 to +901
for (uint32_t i = 0; i < WorkerCount; i++) {
CXPLAT_WORKER* Worker = &WorkerPool->Workers[i];
Stats[i].IdealProcessor = Worker->IdealProcessor;
Stats[i].CumulativeWallTimeUs =
CxPlatTimeDiff64(Worker->Stats.StartedTimeUs, Now);
Stats[i].CumulativeActiveTimeUs = Worker->Stats.CumulativeActiveTimeUs;
}
Comment thread src/core/library.c Outdated
@microsoft microsoft deleted a comment from github-actions Bot Jun 23, 2026
@microsoft microsoft deleted a comment from github-actions Bot Jun 23, 2026
@microsoft microsoft deleted a comment from github-actions Bot Jun 23, 2026
@microsoft microsoft deleted a comment from github-actions Bot Jun 23, 2026
@guhetier guhetier force-pushed the guhetier/worker_statistics_copilot branch from a9694eb to cbd435b Compare June 23, 2026 00:48
@microsoft microsoft deleted a comment from github-actions Bot Jun 23, 2026
@microsoft microsoft deleted a comment from github-actions Bot Jun 23, 2026
guhetier and others added 4 commits June 24, 2026 17:46
Add per-worker statistics accessible via GetParam with NULL handle:
- QUIC_WORKER_STATISTICS struct with IdealProcessor, CumulativeActiveTimeUs,
  CumulativeWallTimeUs per CXPLAT worker
- QUIC_WORKER_STATISTICS_LIST header with WorkerCount and WorkerStatsSize
  for forward-compatible stride-based iteration
- Active time tracked at actual idle points (CxPlatEventQDequeue wait and
  CxPlatSchedulerYield), not Running flag transitions
- Wall time measured from thread start, not worker allocation
- Best-effort snapshot reads (no locks needed for diagnostics)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- QuicTestGetWorkerStatistics: validates buffer size handling, header fields,
  per-worker stat invariants (wall time > 0, active <= wall)
- QuicTestValidateWorkerStatistics: before/after handshake snapshot verifies
  total active time increases after real work

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Guard QUIC_PARAM_GLOBAL_WORKER_STATISTICS case with #ifndef _KERNEL_MODE
  (worker pool API not available in kernel builds)
- Guard test code with #ifdef QUIC_API_ENABLE_PREVIEW_FEATURES for official
  builds that don't define preview features
- Exclude worker stats tests from kernel test driver registration
- Add QUIC_WORKER_STATISTICS and QUIC_WORKER_STATISTICS_LIST to Rust FFI
  bindings (win_bindings.rs and linux_bindings.rs)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Correct QUIC_WORKER_STATISTICS field comments to match implementation
- Fix typo 'that as not' -> 'that has not'
- Remove the Reserved padding field and reorder QUIC_WORKER_STATISTICS so the
  64-bit fields precede IdealProcessor (no manual padding needed)
- Zero output stats so any trailing padding bytes are deterministic
- Regenerate Rust FFI bindings for the new layout

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@guhetier guhetier force-pushed the guhetier/worker_statistics_copilot branch 2 times, most recently from a967015 to ffe80c3 Compare June 25, 2026 04:00
…ED in kernel mode

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@guhetier guhetier force-pushed the guhetier/worker_statistics_copilot branch from ffe80c3 to 96de8bf Compare June 25, 2026 04:32
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