Document fairness counter for push queues#135
Conversation
Reviewer's GuideThis PR introduces and documents a fairness counter for push queues in the Class diagram for ConnectionActor fairness counter additionclassDiagram
class ConnectionActor {
+int high_priority_counter
+int max_high_before_low
+with_fairness(usize)
+process_high_priority_frame()
+process_low_priority_frame()
}
ConnectionActor --> "1" high_priority_push_rx : receives
ConnectionActor --> "1" low_priority_push_rx : receives
class high_priority_push_rx {
+try_recv()
}
class low_priority_push_rx {
+try_recv()
}
Flow diagram for fairness counter in push queue processingflowchart TD
A[Start select! loop] --> B{High-priority frame available?}
B -- Yes --> C[Process high-priority frame]
C --> D[Increment high_priority_counter]
D --> E{high_priority_counter >= max_high_before_low?}
E -- Yes --> F{Low-priority frame available?}
F -- Yes --> G[Process low-priority frame]
G --> H[Reset high_priority_counter]
F -- No --> I[Continue]
E -- No --> I
B -- No --> J{Low-priority frame available?}
J -- Yes --> K[Process low-priority frame]
J -- No --> I
I --> A
H --> A
K --> A
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 48 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThis update enhances documentation for the asynchronous outbound messaging system by introducing and detailing a fairness mechanism in the prioritised write loop. It describes logic to periodically process low-priority frames during high-priority bursts, updates the roadmap to include this task, and clarifies related testing expectations. Changes
Sequence Diagram(s)sequenceDiagram
participant HighPriorityQueue
participant LowPriorityQueue
participant WriteLoop
loop Prioritised Write Loop
WriteLoop->>HighPriorityQueue: Process high-priority frame
alt High-priority burst threshold reached
WriteLoop->>LowPriorityQueue: try_recv() for low-priority frame
opt Low-priority frame available
WriteLoop->>LowPriorityQueue: Process low-priority frame
WriteLoop->>WriteLoop: Reset high-priority counter
end
end
alt Time slice exceeded and low-priority not empty
WriteLoop->>LowPriorityQueue: try_recv() for low-priority frame
end
end
Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 5
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
docs/asynchronous-outbound-messaging-design.md(1 hunks)docs/asynchronous-outbound-messaging-roadmap.md(2 hunks)docs/multi-layered-testing-strategy.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
`docs/**/*.md`: Use the markdown files within the `docs/` directory as a knowled...
docs/**/*.md: Use the markdown files within thedocs/directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
Proactively update the relevant file(s) in thedocs/directory to reflect the latest state when new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve.
Documentation in thedocs/directory must use en-GB-oxendict spelling and grammar, except for the word 'license'.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/multi-layered-testing-strategy.mddocs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...
**/*.md: Validate Markdown files usingmarkdownlint *.md **/*.md.
Runmdformat-allafter any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using thenixieCLI by runningnixie *.md **/*.md.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks in Markdown files must be wrapped at 120 columns.
Tables and headings in Markdown files must not be wrapped.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/multi-layered-testing-strategy.mddocs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`docs/**/multi-layered-testing-strategy.md`: Document advanced testing strategie...
docs/**/multi-layered-testing-strategy.md: Document advanced testing strategies, including concurrency fuzzing with loom and interaction fuzzing with proptest, as well as tests covering streams and push delivery.
📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)
List of files the instruction was applied to:
docs/multi-layered-testing-strategy.md
`docs/**/*.md`: Use British English spelling based on the Oxford English Diction...
docs/**/*.md: Use British English spelling based on the Oxford English Dictionary, except retain US spelling in API names (e.g., 'color').
Use the Oxford comma in lists.
Write headings in sentence case and use Markdown heading levels in order without skipping.
Follow markdownlint recommendations for Markdown formatting.
Always use fenced code blocks with a language identifier; use 'plaintext' for non-code text.
Use '-' as the first level bullet and renumber lists when items change.
Prefer inline links using 'text' or angle brackets around the URL.
Expand any uncommon acronym on first use, e.g., Continuous Integration (CI).
Wrap paragraphs at 80 columns, code at 120 columns, and do not wrap tables.
Use footnotes referenced with '[^label]'.
When embedding figures, use '' and provide concise alt text describing the content.
Add a short description before each Mermaid diagram for screen readers.
📄 Source: CodeRabbit Inference Engine (docs/documentation-style-guide.md)
List of files the instruction was applied to:
docs/multi-layered-testing-strategy.mddocs/asynchronous-outbound-messaging-roadmap.mddocs/asynchronous-outbound-messaging-design.md
`docs/**/asynchronous-outbound-messaging-design.md`: Document the design and imp...
docs/**/asynchronous-outbound-messaging-design.md: Document the design and implementation details for prioritized message queues, error handling, configuration hooks, push handle API, session registry, dead letter queue, and use cases as referenced in the roadmap.
📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
🪛 LanguageTool
docs/multi-layered-testing-strategy.md
[style] ~416-~416: Since ownership is already implied, this phrasing may be redundant.
Context: ...rames are ever lost or reordered within their own channel. When the fairness counter is c...
(PRP_OWN)
docs/asynchronous-outbound-messaging-design.md
[uncategorized] ~145-~145: Possible missing comma found.
Context: ...e counter. An optional time slice (for example 100 µs) can also be configured. When th...
(AI_HYDRA_LEO_MISSING_COMMA)
[style] ~154-~154: Would you like to use the Oxford spelling “summarizes”? The spelling ‘summarises’ is also correct.
Context: ...-priority load. The flow diagram below summarises the fairness logic. ```mermaid flowcha...
(OXFORD_SPELLING_Z_NOT_S)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-test
| - [ ] **Fairness counter** to yield to the low-priority queue after a burst of | ||
| high-priority frames ([Design §3.2.1][design-fairness]). |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Bullet width breaches 80-column rule
The new bullet for the fairness counter is > 80 characters. Re-wrap or split the sentence to satisfy the mandated line-length.
🤖 Prompt for AI Agents
In docs/asynchronous-outbound-messaging-roadmap.md around lines 16 to 17, the
bullet point for the fairness counter exceeds the 80-character line length
limit. Reformat the bullet by wrapping or splitting the sentence into multiple
lines so that no line exceeds 80 characters, ensuring readability and compliance
with the style guide.
| lost or reordered within their own channel. When the fairness counter is | ||
| configured, sequences containing relentless high-priority pushes must still | ||
| observe periodic low-priority frames. |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Minor wording + wrap
- Sentence length exceeds 80 columns – re-wrap.
- “relentless” is informal; “continuous” would match the design doc’s wording.
-When the fairness counter is configured, sequences containing relentless high-priority pushes must still observe periodic low-priority frames.
+When the fairness counter is configured, sequences containing continuous high-priority pushes must still observe periodic low-priority frames.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| lost or reordered within their own channel. When the fairness counter is | |
| configured, sequences containing relentless high-priority pushes must still | |
| observe periodic low-priority frames. | |
| lost or reordered within their own channel. When the fairness counter is | |
| configured, sequences containing continuous high-priority pushes must still | |
| observe periodic low-priority frames. |
🧰 Tools
🪛 LanguageTool
[style] ~416-~416: Since ownership is already implied, this phrasing may be redundant.
Context: ...rames are ever lost or reordered within their own channel. When the fairness counter is c...
(PRP_OWN)
🤖 Prompt for AI Agents
In docs/multi-layered-testing-strategy.md around lines 416 to 418, re-wrap the
sentence to ensure no line exceeds 80 characters and replace the word
"relentless" with "continuous" to align with the design document's terminology.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
docs/asynchronous-outbound-messaging-design.md(1 hunks)docs/multi-layered-testing-strategy.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
`docs/**/*.md`: Use the markdown files within the `docs/` directory as a knowled...
docs/**/*.md: Use the markdown files within thedocs/directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
Proactively update the relevant file(s) in thedocs/directory to reflect the latest state when new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve.
Documentation in thedocs/directory must use en-GB-oxendict spelling and grammar, except for the word 'license'.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/multi-layered-testing-strategy.mddocs/asynchronous-outbound-messaging-design.md
`**/*.md`: Validate Markdown files using `markdownlint *.md **/*.md`. Run `mdfor...
**/*.md: Validate Markdown files usingmarkdownlint *.md **/*.md.
Runmdformat-allafter any documentation changes to format all Markdown files and fix table markup.
Validate Markdown Mermaid diagrams using thenixieCLI by runningnixie *.md **/*.md.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks in Markdown files must be wrapped at 120 columns.
Tables and headings in Markdown files must not be wrapped.
📄 Source: CodeRabbit Inference Engine (AGENTS.md)
List of files the instruction was applied to:
docs/multi-layered-testing-strategy.mddocs/asynchronous-outbound-messaging-design.md
`docs/**/multi-layered-testing-strategy.md`: Document advanced testing strategie...
docs/**/multi-layered-testing-strategy.md: Document advanced testing strategies, including concurrency fuzzing with loom and interaction fuzzing with proptest, as well as tests covering streams and push delivery.
📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)
List of files the instruction was applied to:
docs/multi-layered-testing-strategy.md
`docs/**/*.md`: Use British English spelling based on the Oxford English Diction...
docs/**/*.md: Use British English spelling based on the Oxford English Dictionary, except retain US spelling in API names (e.g., 'color').
Use the Oxford comma in lists.
Write headings in sentence case and use Markdown heading levels in order without skipping.
Follow markdownlint recommendations for Markdown formatting.
Always use fenced code blocks with a language identifier; use 'plaintext' for non-code text.
Use '-' as the first level bullet and renumber lists when items change.
Prefer inline links using 'text' or angle brackets around the URL.
Expand any uncommon acronym on first use, e.g., Continuous Integration (CI).
Wrap paragraphs at 80 columns, code at 120 columns, and do not wrap tables.
Use footnotes referenced with '[^label]'.
When embedding figures, use '' and provide concise alt text describing the content.
Add a short description before each Mermaid diagram for screen readers.
📄 Source: CodeRabbit Inference Engine (docs/documentation-style-guide.md)
List of files the instruction was applied to:
docs/multi-layered-testing-strategy.mddocs/asynchronous-outbound-messaging-design.md
`docs/**/asynchronous-outbound-messaging-design.md`: Document the design and imp...
docs/**/asynchronous-outbound-messaging-design.md: Document the design and implementation details for prioritized message queues, error handling, configuration hooks, push handle API, session registry, dead letter queue, and use cases as referenced in the roadmap.
📄 Source: CodeRabbit Inference Engine (docs/asynchronous-outbound-messaging-roadmap.md)
List of files the instruction was applied to:
docs/asynchronous-outbound-messaging-design.md
🪛 LanguageTool
docs/multi-layered-testing-strategy.md
[style] ~416-~416: Since ownership is already implied, this phrasing may be redundant.
Context: ...rames are ever lost or reordered within their own channel. When the fairness counter is c...
(PRP_OWN)
docs/asynchronous-outbound-messaging-design.md
[uncategorized] ~145-~145: Possible missing comma found.
Context: ...e counter. An optional time slice (for example 100 µs) can also be configured. When th...
(AI_HYDRA_LEO_MISSING_COMMA)
[style] ~158-~158: Would you like to use the Oxford spelling “summarizes”? The spelling ‘summarises’ is also correct.
Context: ...sable MD033 --> The flow diagram below summarises the fairness logic. The d...
(OXFORD_SPELLING_Z_NOT_S)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build-test
🔇 Additional comments (2)
docs/asynchronous-outbound-messaging-design.md (1)
158-162: Accessibility note looks good — thanks for adding the<description>tag.The diagram description is concise, wrapped to 80 columns, and satisfies
md041.docs/multi-layered-testing-strategy.md (1)
416-418: Wording and wrapping now comply with guidelines.The sentence uses “continuous”, is below 80 columns, and reads cleanly.
No further changes required.
| An optional time slice (for example 100 µs) can also be configured. When the | ||
| elapsed time spent handling high-priority frames exceeds this slice, and the low | ||
| queue is not empty, the actor yields to a low-priority frame. Application | ||
| builders expose `with_fairness(usize)` to set the threshold, defaulting to 16. | ||
| An additional `with_fairness_time_slice(Duration)` method allows tuning of the | ||
| time-based yield. Setting the counter to zero preserves the original strict | ||
| ordering. |
There was a problem hiding this comment.
🧹 Nitpick (assertive)
Consider consolidating the two builder methods into a single FairnessConfig.
with_fairness(usize) and with_fairness_time_slice(Duration) expose two entry
points for what is essentially one concern. A small struct or builder, e.g.
pub struct FairnessConfig {
counter: usize,
time_slice: Option<Duration>,
}passed via with_fairness(cfg: FairnessConfig) would avoid API sprawl,
eliminate future breaking changes if more knobs are added, and make the
relationship between the two parameters explicit.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~145-~145: Possible missing comma found.
Context: ...e counter. An optional time slice (for example 100 µs) can also be configured. When th...
(AI_HYDRA_LEO_MISSING_COMMA)
🤖 Prompt for AI Agents
In docs/asynchronous-outbound-messaging-design.md around lines 145 to 151, the
two separate builder methods with_fairness(usize) and
with_fairness_time_slice(Duration) should be consolidated into a single method
that accepts a FairnessConfig struct. Define a FairnessConfig struct containing
both the counter and an optional time_slice field, then replace the two methods
with one that takes this struct as a parameter. This change simplifies the API,
groups related configuration together, and makes it easier to extend in the
future.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Testing
make fmtmake lintmake testmdformat-all docs/asynchronous-outbound-messaging-design.md docs/asynchronous-outbound-messaging-roadmap.md docs/multi-layered-testing-strategy.mdmarkdownlint --fix ...nixie docs/asynchronous-outbound-messaging-design.md docs/asynchronous-outbound-messaging-roadmap.md docs/multi-layered-testing-strategy.mdhttps://chatgpt.com/codex/tasks/task_e_685c7f19b80c8322ac11ef825cf6e86c
Summary by Sourcery
Document the new fairness mechanism for low-priority frames in the push queue design, update the roadmap with a task to implement fairness in ConnectionActor, and extend the testing strategy to cover the fairness counter behavior.
Documentation: