refactor(poll_descriptor): split debug_log_throttle submodule (#4404 inc 1) - #4644
Merged
Conversation
…inc 1) #4404 asks for the decomposition of poll_descriptor/mod.rs and its poll_binding_process_descriptor god-function. The god-function itself fuses the session-hit / session-miss / flowless arms and is guarded by load-bearing invariants (single-recycle, CoS guarantee-guard, packet-range/verifier-sensitive logic); per the issue it needs /triple-review and is left untouched here. This is a bounded first increment of pure code-motion. Move the cold-path debug-log throttle unit out of mod.rs into a new sibling submodule poll_descriptor/debug_log_throttle.rs: - the two #4120 interval caps SESSION_MISS_DEBUG_LOG_CAP and POLICY_DENY_DEBUG_LOG_CAP (kept module-private, only referenced inside the moved code), - the two pure u64 -> bool predicates session_miss_debug_log_allowed and policy_deny_debug_log_allowed (now pub(super) so the mod.rs call sites in poll_binding_process_descriptor still reach them), - the debug_log_throttle_tests pinned-contract test module (the #4120 RED-on-revert guard that proves the throttle takes no topology input). mod.rs gains a `mod debug_log_throttle;` declaration and a `use` import. This unit was chosen because it has ZERO cross-references back into mod.rs — the predicates depend on no dataplane type, so it is the cleanest available boundary — and it directly matches the issue's stated fix of outlining the cold-path debug logging. Behavior, the public visibility surface, and all three test cases are identical; the bodies move verbatim. Validation: full `cargo test` (CARGO_TARGET_DIR=/tmp/cargo-4404) passes across every binary — main lib 3739 passed / 0 failed (the 3 moved tests now run as afxdp::poll_descriptor::debug_log_throttle::debug_log_throttle_tests::*), plus 60 + 8 + 22 + 1 in the other binaries, 0 failed. The new file is rustfmt-clean at edition 2024; mod.rs changed lines match surrounding style. Module doc (mod.rs header) and _Log.md updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015oARShYtiJJ2H4UB4nXGqi
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the afxdp::poll_descriptor module by extracting the cold-path debug-log throttle caps/predicates (and their pinned-contract tests) into a dedicated sibling submodule, keeping poll_binding_process_descriptor logic unchanged while reducing local clutter and isolating a dependency-free unit.
Changes:
- Added
poll_descriptor::debug_log_throttlesubmodule and re-exported the two throttle predicates to the parent module viapub(super). - Removed the throttle caps/predicates and their tests from
poll_descriptor/mod.rs, wiring call sites through auseimport. - Logged the refactor increment in
_Log.mdper repository practice.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| userspace-dp/src/afxdp/poll_descriptor/mod.rs | Declares/imports the new debug_log_throttle module and removes the inlined throttle unit/tests (pure code motion). |
| userspace-dp/src/afxdp/poll_descriptor/debug_log_throttle.rs | New module containing the throttle caps, predicates, and the pinned-contract tests moved verbatim. |
| _Log.md | Records the #4404 increment-1 refactor action and validation summary. |
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.
Addresses #4404 (increment 1: extract/split
debug_log_throttle; further increments tracked).What
Pure code-motion split of the cold-path
debug-logthrottle unit out ofuserspace-dp/src/afxdp/poll_descriptor/mod.rsinto a new sibling submodulepoll_descriptor/debug_log_throttle.rs.Moved verbatim:
SESSION_MISS_DEBUG_LOG_CAP/POLICY_DENY_DEBUG_LOG_CAP(kept module-private),u64 -> boolpredicatessession_miss_debug_log_allowed/policy_deny_debug_log_allowed(nowpub(super)so thepoll_binding_process_descriptorcall sites still reach them),debug_log_throttle_testspinned-contract test module (code-quality: leftover test-env 'is_trust_flow' hardcode (ifindex==5 || zone=='lan' || 10.x src) gates debug logging in the session-miss cold path — defeats the dbg rate-caps + floods logs on any real 10.x LAN (fable-163 F27) #4120 RED-on-revert guard).mod.rsgains amod debug_log_throttle;declaration + auseimport.Why this unit / why pure code-motion
This unit has zero cross-references back into mod.rs — the predicates depend on no
dataplane type — so it is the cleanest available boundary, and it directly matches the
issue's stated fix of outlining the cold-path debug logging. Behavior, the public
visibility surface, and all three test cases are identical; the bodies move verbatim.
The
poll_binding_process_descriptorgod-function itself (session-hit / session-miss /flowless arm fusion) is not touched — per the issue it needs
/triple-reviewbecauseit carries the single-recycle, CoS guarantee-guard, and packet-range/verifier-sensitive
invariants. Those further increments remain tracked on #4404.
Validation
Full
cargo test(CARGO_TARGET_DIR=/tmp/cargo-4404) passes across every binary:afxdp::poll_descriptor::debug_log_throttle::debug_log_throttle_tests::*)New file is rustfmt-clean at edition 2024;
mod.rschanged lines match surrounding style.Module doc (
mod.rsheader) +_Log.mdupdated.🤖 Generated with Claude Code
https://claude.ai/code/session_015oARShYtiJJ2H4UB4nXGqi