Skip to content

⚡ Bolt: Batch producer wakeups outside spinlock - #45

Open
maxugly wants to merge 1 commit into
mainfrom
bolt-batch-producer-wakeups-6251807817317983420
Open

⚡ Bolt: Batch producer wakeups outside spinlock#45
maxugly wants to merge 1 commit into
mainfrom
bolt-batch-producer-wakeups-6251807817317983420

Conversation

@maxugly

@maxugly maxugly commented Aug 6, 2026

Copy link
Copy Markdown
Owner

💡 What: Batched netif_wake_queue outside the spinlock in nata_poll.
🎯 Why: Reduces lock contention on priv->lock by avoiding repeated producer queue wakeups within the short spinlock during NAPI receive dequeues.
📊 Impact: Reduces overhead in the high-frequency polling hotpath, lowering latency and improving throughput.
🔬 Measurement: Can be verified by running sudo ./scripts/nata-bench-once.sh and observing iperf3 UDP/TCP throughput or checking natactl status interrupts/drops.


PR created automatically by Jules for task 6251807817317983420 started by @maxugly

Summary by CodeRabbit

  • Performance Improvements
    • Improved network packet processing efficiency by batching queue wakeups during polling.
    • Reduced unnecessary repeated wakeups while processing packets, helping minimize locking overhead.

Co-authored-by: maxugly <64644401+maxugly@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

nata_poll no longer wakes the peer TX queue after each RX dequeue. It performs one wakeup after a non-empty RX batch and outside the spinlock. The learning entry documents this pattern.

Changes

NAPI wakeup batching

Layer / File(s) Summary
Batch and defer peer TX wakeup
.jules/bolt.md, module/nata_net.c
nata_poll removes per-dequeue wakeups from the locked RX path and performs one peer TX queue wakeup after a non-empty batch. The learning entry documents the batching guidance.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • maxugly/nata#31: Implements the same peer TX wakeup batching and deferral in nata_poll.
  • maxugly/nata#33: Modifies nata_poll to batch the peer TX queue wakeup outside the spinlock.
  • maxugly/nata#35: Batches nata_wake_tx_peer calls after RX processing.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes batching producer wakeups outside the spinlock, which is the main change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-batch-producer-wakeups-6251807817317983420

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@module/nata_net.c`:
- Around line 49-51: Update the RX consumption flow around sim_rx_dequeue() to
track consumed slots independently of delivered packet count, including ret < 0
cases that clear valid and advance the tail. Call nata_wake_tx_peer() whenever
any slot was freed, while retaining work for packet-delivery accounting.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f47c41f-e0f3-4a97-87bc-ec59bf5be297

📥 Commits

Reviewing files that changed from the base of the PR and between 6d5b3ed and 7077f18.

📒 Files selected for processing (2)
  • .jules/bolt.md
  • module/nata_net.c

Comment thread module/nata_net.c
Comment on lines +49 to +51
/* Batch producer wakeups outside the spinlock to minimize contention overhead */
if (work > 0)
nata_wake_tx_peer(priv, is_dev0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify the dequeue return contract and all queue stop/wake paths.
rg -n -C 10 '\bsim_rx_dequeue\s*\(|\bnetif_(stop|wake)_queue\s*\(|\bcheck_tx_full\s*\(' module

Repository: maxugly/nata

Length of output: 7908


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'nata_net.c context:\n'
cat -n module/nata_net.c | sed -n '24,60p'

printf '\nsim_rx_dequeue implementation:\n'
cat -n module/nata_blk.c | sed -n '184,280p'

printf '\nTX enqueue/stop contexts with netif_queue_stopped/queue wake:\n'
rg -n -C 5 'netif_queue_stopped|netif_wake_queue|netif_stop_queue|sim_tx_packet|check_tx_full' module

Repository: maxugly/nata

Length of output: 11513


Wake the producer after every consumed RX slot.

sim_rx_dequeue() returns <0 after clearing valid and advancing the tail. The ret < 0 branch continues without incrementing work, so a full stopped TX queue back on the same ring does not get woken. Track freed/consumed slots separately and call nata_wake_tx_peer() whenever a slot was freed, not only when packets were delivered.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@module/nata_net.c` around lines 49 - 51, Update the RX consumption flow
around sim_rx_dequeue() to track consumed slots independently of delivered
packet count, including ret < 0 cases that clear valid and advance the tail.
Call nata_wake_tx_peer() whenever any slot was freed, while retaining work for
packet-delivery accounting.

Source: Coding guidelines

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