Add global worker statistics param (QUIC_PARAM_GLOBAL_WORKER_STATISTICS)#6115
Draft
guhetier wants to merge 5 commits into
Draft
Add global worker statistics param (QUIC_PARAM_GLOBAL_WORKER_STATISTICS)#6115guhetier wants to merge 5 commits into
guhetier wants to merge 5 commits into
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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_STATISTICSandQUIC_WORKER_STATISTICS_LIST, plus the new global param ID inmsquic.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 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 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; | ||
| } |
a9694eb to
cbd435b
Compare
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>
a967015 to
ffe80c3
Compare
…ED in kernel mode Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ffe80c3 to
96de8bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Add per-worker statistics accessible via
MsQuic->GetParam(NULL, QUIC_PARAM_GLOBAL_WORKER_STATISTICS, ...):QUIC_WORKER_STATISTICSstruct:IdealProcessor,CumulativeActiveTimeUs,CumulativeWallTimeUsper CXPLAT workerQUIC_WORKER_STATISTICS_LISTheader withWorkerCountandWorkerStatsSizefor forward-compatible stride-based iterationCxPlatEventQDequeuewait andCxPlatSchedulerYield), notRunningflag transitionsPreview-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.hcomments.