Skip to content

refactor(queue): remove retain from PacketQueue trait - #206

Merged
BobAnkh merged 1 commit into
mainfrom
refactor/droptail-retain
Jul 14, 2026
Merged

refactor(queue): remove retain from PacketQueue trait#206
BobAnkh merged 1 commit into
mainfrom
refactor/droptail-retain

Conversation

@Centaurus99

Copy link
Copy Markdown
Member

The trait-level retain was buggy in every impl (never updated now_bytes after dropping packets) and is only used by TBF's DropTail queue, so maintaining it on the trait isn't worth it. Remove it from the trait and reimplement it as an inherent method on DropTailQueue<P> that correctly maintains now_bytes.

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

This PR refactors the bandwidth queue abstraction by removing the trait-level retain method (previously buggy / inconsistent across implementations) and reintroducing retain only where it is needed (DropTail), with correct now_bytes accounting.

Changes:

  • Removed retain from the PacketQueue trait and deleted the corresponding impls from all queue types.
  • Added an inherent DropTailQueue::retain that decrements now_bytes when packets are dropped by the predicate.
  • Kept the token-bucket shrink behavior supported via the concrete DropTailQueue API.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rattan-core/src/cells/bandwidth/queue/mod.rs Removes retain from the PacketQueue trait surface.
rattan-core/src/cells/bandwidth/queue/infinite.rs Drops the no-longer-needed retain impl.
rattan-core/src/cells/bandwidth/queue/droptail.rs Adds DropTailQueue::retain with now_bytes maintenance.
rattan-core/src/cells/bandwidth/queue/drophead.rs Drops the no-longer-needed retain impl.
rattan-core/src/cells/bandwidth/queue/codel.rs Drops the no-longer-needed retain impl.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread rattan-core/src/cells/bandwidth/queue/droptail.rs
Comment thread rattan-core/src/cells/bandwidth/queue/droptail.rs

@BobAnkh BobAnkh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@BobAnkh
BobAnkh merged commit 0410b0a into main Jul 14, 2026
19 checks passed
@BobAnkh
BobAnkh deleted the refactor/droptail-retain branch July 14, 2026 05:39
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