Skip to content

v4.2.12#83

Merged
Power2All merged 3 commits into
masterfrom
v4.2.12
May 31, 2026
Merged

v4.2.12#83
Power2All merged 3 commits into
masterfrom
v4.2.12

Conversation

@Power2All

@Power2All Power2All commented May 31, 2026

Copy link
Copy Markdown
Owner

v4.2.12

  • Applied UDP traffic control performance and improvements
  • Introduced a new optional config for further optimization: receive_method. This can be "auto", "recvmmsg" or "io_uring". By default, "recvmmsg" is used, but io_uring can be used when you received a lot of traffic

Summary by CodeRabbit

Release Notes v4.2.12

  • New Features

    • Added configurable UDP receive method selection (recvmmsg, auto, or io_uring) for optimizing UDP traffic control performance based on system capabilities.
  • Documentation

    • Updated README with UDP receive method configuration details and environment variable override documentation.
  • Chores

    • Bumped version to 4.2.12.
    • Updated dependencies: uuid, redis, and reqwest.
    • Updated Docker image and build scripts to v4.2.12.

@Power2All Power2All self-assigned this May 31, 2026
@Power2All Power2All added the enhancement New feature or request label May 31, 2026
@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR bumps version to 4.2.12 and introduces configurable UDP receive method selection on Linux (recvmmsg or io_uring). The feature adds a new UdpReceiveMethod enum, two receiving backends (batch_recv via recvmmsg, io_uring_recv via io_uring), refactors UdpPacket to use SmallVec, and integrates backend selection into UdpServer with fallback logic.

Changes

UDP Receive Method Configuration and Implementation

Layer / File(s) Summary
Version bump and release documentation
Cargo.toml, README.md, docker/Dockerfile, docker/build.bat, torrust-actix.desktop, version.bat
Version incremented from 4.2.11 to 4.2.12 across build manifests, Docker configuration, and desktop entry; README documents the new UDP receive method feature and environment variable UDP_0_RECEIVE_METHOD; version.bat script added to automate version propagation across files.
UDP receive method configuration contract
src/config/enums.rs, src/config/enums/udp_receive_method.rs, src/config/impls/configuration.rs, src/config/structs/udp_trackers_config.rs
UdpReceiveMethod enum defined with three variants (recvmmsg as default, auto, io_uring); configuration initialization sets receive_method default; env_overrides() parses UDP_{i}_RECEIVE_METHOD environment variables with case-insensitive fallback; UdpTrackersConfig struct extended with #[serde(default)] field for backward compatibility.
UDP packet data structure refactoring
src/udp/structs/udp_packet.rs, src/udp/structs/udp_server.rs, src/udp/impls/parse_pool.rs
UdpPacket.data converted from fixed-size array to SmallVec<[u8; 256]>, removing the explicit data_len field; UdpServer struct extended with sockets: Vec<Arc<UdpSocket>> and receive_method field; ParsePool updated to use packet.data.as_slice() and packet.data.to_vec() instead of explicit length-based slicing.
Linux UDP receive implementations
src/udp/impls.rs, src/udp/impls/batch_recv.rs, src/udp/impls/io_uring_recv.rs
batch_recv.rs implements RecvBatch for batched recvmmsg receiving with fixed-size slot arrays, unsafe FFI calls, and sockaddr_to_socketaddr conversion for IPv4/IPv6; io_uring_recv.rs implements is_available() probe and run() loop that pre-allocates receive slots, submits RecvMsg operations, polls completions with timeout, constructs UdpPackets, and enqueues to parse_pool.
UDP server socket management and backend selection
src/udp/impls/udp_server.rs, src/udp/udp.rs, src/main.rs
UdpServer::new builds socket sets via OS-specific logic (multiple sockets with SO_REUSEPORT on Linux, single socket on non-Linux); start() method routes receive backend based on receive_method and runtime availability (io_uring if requested and available, else recvmmsg on Linux, standard recv on non-Linux); receive loops drain datagrams into ParsePool as SmallVec-backed UdpPackets; udp_service function and main.rs initialization thread through the receive_method parameter.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

The changes involve substantial logic density across multiple layers: unsafe FFI code with libc structures in batch_recv, intricate io_uring state machine and submission/completion handling, OS-conditional socket configuration, and coordinated refactoring of the packet structure and receive loops. While individual sections follow clear patterns, the full context requires understanding the interplay between configuration, multiple receive backends, and their integration into the server runtime.

Possibly related PRs

  • Power2All/torrust-actix#78: Refactors UDP environment variable parsing helpers in Configuration::env_overrides(), which overlaps with the UDP receive method configuration logic added in this PR.

🐰 Version dance across the stable,
Recvmmsg and io_uring on the table,
SmallVec buffers lean and fleet,
UDP packets batched, oh how neat!
Linux sockets now can choose their pace.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 24.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'v4.2.12' is a version number, not a descriptive summary of the changes. While it's related to the version bump in the changeset, it doesn't convey the primary change (UDP performance improvements with configurable receive_method). Consider using a more descriptive title such as 'Add configurable UDP receive method (io_uring, recvmmsg, auto)' or 'Improve UDP performance with selectable receive methods' to better communicate the main feature to reviewers.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 v4.2.12

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Trivy (0.69.3)

Trivy execution failed: 2026-05-31T14:41:47Z FATAL Fatal error run error: fs scan error: scan error: scan failed: failed analysis: post analysis error: post analysis error: kubernetes scan error: fs filter error: fs filter error: walk error range error: stat .coderabbit-opengrep-fallback.yml: no such file or directory: range error: stat .coderabbit-opengrep-fallback.yml: no such file or directory


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 and usage tips.

@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: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
version.bat (1)

1-35: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Convert to Windows line endings (CRLF).

Batch files with Unix line endings (LF-only) can malfunction on Windows due to parser bugs at 512-byte boundaries, especially affecting GOTO and CALL statements. This script must use CRLF line endings to function reliably.

🔧 Fix line endings

Run one of the following commands to convert the file:

Using Git:

git config core.autocrlf true
git add --renormalize version.bat

Using dos2unix (if available):

unix2dos version.bat

Using PowerShell:

(Get-Content version.bat -Raw).Replace("`n", "`r`n") | Set-Content version.bat -NoNewline
🤖 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 `@version.bat` around lines 1 - 35, The file version.bat currently has Unix LF
line endings which can break Windows batch parsing (affecting scripts that use
constructs like set "TA_VER=%~1" and the long powershell -Command block);
convert version.bat to CRLF (Windows) line endings so the batch parser behaves
reliably—e.g., run git add --renormalize after setting core.autocrlf=true, or
run unix2dos/PowerShell conversion, then verify the file contains CRLF endings
and commit the change.
🤖 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 `@Cargo.toml`:
- Line 43: The Cargo.toml bumps for uuid, redis, and reqwest appear unrelated to
the UDP changes — verify each bump in Cargo.toml (uuid, redis, reqwest) is
intentional: confirm where they are actually used (UUID in websocket/API code,
redis in cache backend code, reqwest in API tests and Sentry feature), and
either keep the version bumps and run tests/ci to ensure compatibility and
update Cargo.lock, or revert the version changes if they were accidental;
additionally add a short comment in Cargo.toml or the PR description explaining
why each bump was necessary to avoid future confusion.

In `@README.md`:
- Around line 571-573: In the changelog entry under the "v4.2.12" heading, fix
the tense in the sentence referencing the "receive_method" option: change "when
you received a lot of traffic" to "when you receive a lot of traffic" so the
sentence reads that io_uring can be used when you receive a lot of traffic.

In `@src/udp/impls/udp_server.rs`:
- Around line 135-142: The current logic only sets use_io_uring true when
receive_method == UdpReceiveMethod::io_uring, so UdpReceiveMethod::Auto never
selects io_uring; change the condition used to compute requested/available so
Auto requests io_uring (e.g., let requested = matches!(receive_method,
UdpReceiveMethod::io_uring | UdpReceiveMethod::Auto)); then compute available =
crate::udp::impls::io_uring_recv::is_available() and set use_io_uring =
requested && available, preserving the warning/log behavior (adjust messages to
indicate Auto fell back if requested was Auto and available false).
- Around line 220-249: The receive loop currently breaks on any non-WouldBlock
error from socket.readable() and socket.try_io(...) which can permanently stop
the task on transient errors; change handling so transient errno are not
terminal: for the socket.readable() branch check the error kind and if it's
ErrorKind::Interrupted (or other temporary I/O errors) just continue the outer
loop instead of break, and inside the match replace the Err(_) => break arm with
logic that inspects e.kind() and continues for transient errors (Interrupted,
WouldBlock already handled) but only break/close for non-transient errors;
reference socket.readable(), socket.try_io(Interest::READABLE, ||
batch.recv(fd)), batch.recv(fd) and the Err(_) arm to locate places to change.

---

Outside diff comments:
In `@version.bat`:
- Around line 1-35: The file version.bat currently has Unix LF line endings
which can break Windows batch parsing (affecting scripts that use constructs
like set "TA_VER=%~1" and the long powershell -Command block); convert
version.bat to CRLF (Windows) line endings so the batch parser behaves
reliably—e.g., run git add --renormalize after setting core.autocrlf=true, or
run unix2dos/PowerShell conversion, then verify the file contains CRLF endings
and commit the change.
🪄 Autofix (Beta)

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: 608c2bd4-0fdc-4a6a-a4a9-c746c1bd08a9

📥 Commits

Reviewing files that changed from the base of the PR and between 6a227a4 and 97cdf8f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • Cargo.toml
  • README.md
  • docker/Dockerfile
  • docker/build.bat
  • src/config/enums.rs
  • src/config/enums/udp_receive_method.rs
  • src/config/impls/configuration.rs
  • src/config/structs/udp_trackers_config.rs
  • src/main.rs
  • src/udp/impls.rs
  • src/udp/impls/batch_recv.rs
  • src/udp/impls/io_uring_recv.rs
  • src/udp/impls/parse_pool.rs
  • src/udp/impls/udp_server.rs
  • src/udp/structs/udp_packet.rs
  • src/udp/structs/udp_server.rs
  • src/udp/udp.rs
  • torrust-actix.desktop
  • version.bat

Comment thread Cargo.toml
Comment thread README.md
Comment thread src/udp/impls/udp_server.rs
Comment thread src/udp/impls/udp_server.rs
@Power2All Power2All merged commit 65923e0 into master May 31, 2026
2 checks passed
@Power2All Power2All deleted the v4.2.12 branch May 31, 2026 15:16
@coderabbitai coderabbitai Bot mentioned this pull request Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant