Skip to content

fix: harden SV pacing estimator and isolate unrelated traffic - #50

Merged
masarray merged 5 commits into
mainfrom
fix/sv-pacing-review-followup
Aug 3, 2026
Merged

fix: harden SV pacing estimator and isolate unrelated traffic#50
masarray merged 5 commits into
mainfrom
fix/sv-pacing-review-followup

Conversation

@masarray

@masarray masarray commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to PR #49 addressing both review findings before the transport is treated as complete.

Stable interval acquisition

  • does not activate pacing from a single observed interval;
  • requires four mutually consistent intervals before a nominal SV interval becomes active;
  • resets the candidate when observations disagree;
  • ignores long scheduler stalls and large deviations after pacing is active;
  • adds deterministic tests proving a late first interval cannot permanently reduce the wire rate.

Independent traffic paths

  • moves pacing waits to a per-SV-stream semaphore;
  • limits the shared Npcap injection semaphore to the short SendPacket critical section;
  • allows PTP, GOOSE and other non-SV traffic to pass while an SV stream is waiting for its deadline;
  • keeps independent pacing state for every source/destination/APPID/VLAN stream identity.

Tests

Adds coverage for:

  • late first-interval rejection;
  • inconsistent candidate rejection;
  • long scheduler-stall rejection after activation;
  • conservative tracking of nearby steady intervals.

Frame encoding, smpCnt, quality, timestamps, VLAN, APPID and capture behavior remain unchanged.

@masarray
masarray marked this pull request as ready for review August 3, 2026 07:12

masarray commented Aug 3, 2026

Copy link
Copy Markdown
Owner Author

Final validation and review-follow-up evidence:

  • Public-source/provenance/license verification passed.
  • Windows Release solution build succeeded with 0 warnings and 0 errors.
  • AR.Iec61850.Tests: 442/442 passed, including four new pacing-estimator tests.
  • A single scheduler-late interval no longer activates pacing; four mutually consistent intervals are required.
  • Long stalls and large deviations cannot drag an active nominal rate away from its steady interval.
  • SV pacing waits are protected by a per-stream semaphore.
  • The shared Npcap injection semaphore is now held only around SendPacket, so PTP, GOOSE and unrelated SV streams are not blocked while one SV stream waits for its deadline.
  • Test diagnostic artifact uploaded successfully.

@masarray
masarray merged commit d1eba74 into main Aug 3, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09453e8cd9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +49 to +52
if (intervalTicks >= minimumAccepted && intervalTicks <= maximumAccepted)
{
NominalIntervalTicks = (long)Math.Round(
(NominalIntervalTicks * 0.9) + (intervalTicks * 0.1));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Stop moderate lateness from ratcheting the SV interval

When pacing is active and one send is moderately late—for example, 300 ticks against a 250-tick nominal—this branch accepts the observation and raises the nominal to 255. Because PaceSampledValuesAsync subsequently enforces at least that new nominal between commits, normal 250-tick caller traffic cannot produce a shorter observation to restore the rate; recurring scheduler or injection delays below the 1.5× cutoff can therefore ratchet an SV stream progressively slower. Require consistent independent evidence before updating an active nominal rather than feeding individual paced intervals back into it.

AGENTS.md reference: AGENTS.md:L173-L178

Useful? React with 👍 / 👎.

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.

1 participant