Skip to content

perf(shred): skip primary FEC reparse — reduce packet-worker overhead#91

Merged
Lythaeon merged 2 commits into
mainfrom
perf/fec-primary-reparse-skip
Apr 9, 2026
Merged

perf(shred): skip primary FEC reparse — reduce packet-worker overhead#91
Lythaeon merged 2 commits into
mainfrom
perf/fec-primary-reparse-skip

Conversation

@Lythaeon

@Lythaeon Lythaeon commented Apr 9, 2026

Copy link
Copy Markdown
Owner

Description

Reduce packet-worker FEC overhead without changing SOF API contracts or feature scope.
This PR removes a redundant primary-packet shred reparse in the FEC ingest path by reusing the already-validated parsed header that packet workers already carry.

Changes

Detailed list of what changed:

  • crates/sof-observer/src/app/runtime/runloop/packet_workers.rs: pass the existing ParsedShredHeader into the FEC recoverer instead of forcing the recoverer to parse the primary packet bytes again.
  • crates/sof-observer/src/shred/fec/core.rs: change primary-packet ingest to consume ParsedShredHeader and use it for slot/FEC-set/variant routing, avoiding a second full parse on the hot path.
  • Any architecture/runtime/infra implications: none; this is an internal hot-path optimization inside the existing packet-worker/FEC pipeline.

For slice-related changes, include:

  • Affected slices: app/runtime/runloop, shred/fec.
  • Cross-slice communication changes (if any) and why: packet workers now hand the FEC layer the parsed header they already own, removing duplicated work across the runloop and shred slices.
  • Migration requirements (if any): none.

Motivation

Business motivation:

  • Improve throughput on the current feature set before expanding scope.

Technical motivation:

  • Packet workers already parse and retain ParsedShredHeader for accepted packets.
  • Repeating full shred parsing inside FecRecoverer::ingest_packet wastes CPU on the primary-path hot loop.
  • Reusing the existing header reduces duplicated parsing without changing behavior.

Alternative approaches considered:

  • Leaving the duplicate parse in place.
  • Bundling this with a larger FEC/storage refactor instead of landing the smallest measurable improvement first.

Scope and impact

  • Affected slices: packet-worker/FEC hot path.
  • Data/API changes: none.
  • Backward compatibility: fully backward compatible.
  • Performance impact: positive in the primary FEC profile fixture; local A/B dropped from 110 ms to 94 ms over 50,000 iterations.
  • Security impact: none.

Testing

  • Unit tests
  • Integration tests
  • Manual verification
  • Performance checks (if applicable)
  • Security checks (if applicable)

Commands/results:

cargo fmt --all
cargo test -p sof --lib --no-run
cargo test -p sof --lib packet_worker_ -- --nocapture
cargo test -p sof --lib purge_older_than_removes_old_sets -- --nocapture
SOF_PACKET_WORKER_FEC_PROFILE_ITERS=50000 CARGO_TARGET_DIR=/home/ac/.cache/sof-fec-current/target cargo test -p sof --lib packet_worker_primary_fec_profile_fixture -- --ignored --nocapture
cd /tmp/sof-baseline-import-hygiene && SOF_PACKET_WORKER_FEC_PROFILE_ITERS=50000 CARGO_TARGET_DIR=/home/ac/.cache/sof-fec-baseline/target cargo test -p sof --lib packet_worker_primary_fec_profile_fixture -- --ignored --nocapture

Results: passed.

Related issues and documentation

  • Fixes:
  • Related: packet/FEC perf roadmap follow-up in docs/operations/tx-reconstruction-and-packet-processing-todo-2026-03-24.md
  • Architecture docs: docs/architecture/README.md
  • Relevant ARD/ADR:
  • Operations/runbook updates: none.

Reviewer checklist

  • Code follows project standards and architecture constraints
  • Slice boundaries are respected (docs/architecture/ard/0003-slice-dependency-contracts.md)
  • Tests added/updated and passing
  • Documentation updated (README/docs/operations as needed)
  • No undocumented breaking change
  • Performance trade-offs documented where relevant
  • Security considerations addressed where relevant

Additional notes

This PR is independent of the completed-dataset perf work and can be reviewed directly on top of refactor/import-hygiene.

@Lythaeon Lythaeon force-pushed the refactor/import-hygiene branch from 02043f4 to 6efd16c Compare April 9, 2026 13:18
@Lythaeon Lythaeon force-pushed the perf/fec-primary-reparse-skip branch from 87842d6 to aaca6c5 Compare April 9, 2026 13:21
@Lythaeon Lythaeon changed the base branch from refactor/import-hygiene to main April 9, 2026 13:21
@Lythaeon Lythaeon merged commit c7ab441 into main Apr 9, 2026
2 of 4 checks passed
@Lythaeon Lythaeon deleted the perf/fec-primary-reparse-skip branch April 9, 2026 13:56
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