← Back to Pull requests

[IO_URING] Accept immutable buffers for unregistered writes #402

Open
rksharma-owg opened this pull request with 126 lines diff across 3 files
View on GitHub
rksharma-owg rksharma-owg commented on Oct 06, 2026 03:08 UTC
Author

IORing.Request.write required mutable buffers even though a write only reads from them. Add UnsafeRawBufferPointer overloads for both ordinary file descriptors and registered file slots, retaining the existing mutable-buffer signatures and function references.

The new overloads use the existing write request encoder. Their documentation explains buffer lifetime, offsets, completion context and partial writes. Regression tests check the resulting operation, descriptor, address, length, offset and context. A real io_uring pipe test writes an immutable buffer and verifies the received bytes.

Local Linux ARM64 Swift 6.4 validation passed: 81 XCTest cases and 7 Swift Testing tests, including real io_uring execution. The immutable-buffer tests fail to compile before the overloads are added. Mutable function references and inferred buffer-construction calls compile with the fix.

The cloud API breakage check passes against the refreshed target branch.

Fork preflight passed all 49 enabled jobs for 92481cc05652e561623eb32c1411d5d2e4b7fd4d against 486d48c80fce32823218000cf8563d9b4bbbf4a9: Linux, macOS, Windows, FreeBSD, Android emulator tests, static Linux/Wasm SDK builds, ABI-stable macOS builds, CMake and applicable soundness/API checks. Standard container runs skip io_uring when unavailable; the separate kernel write/read-back job executed and passed. Upstream-disabled checks remain inapplicable.

Fixes #400.

Diff: 126 lines (+126 / -0) across 3 files Reviewer: FranzBusch Review duration: 1905m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.35) × (1 − Review Confidence (0.88)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.35 · 126 lines diff across 3 files
0.35
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.96 · 1 substantive comment(s)
0.96
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
88%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.290
Real PR Conversation Timeline
2 items
FranzBusch FranzBusch commented on code on Oct 06, 2026 08:21 UTC
Code Review
Sources/System/IORing/IORequest.swift:1
@@ -385,6 +385,26 @@ extension IORing.Request {
         )
     }
 
+    @inlinable public static func write(
+        _ buffer: UnsafeRawBufferPointer,
+        into file: IORing.RegisteredFile,
+        at offset: UInt64 = 0,
+        context: UInt64 = 0
+    ) -> IORing.Request {
+        // The shared request encoder uses a mutable pointer, but writes only read the buffer.
+        write(UnsafeMutableRawBufferPointer(mutating: buffer), into: file, at: offset, context: context)
+    }
+
+    @inlinable public static func write(

While we are here can we add doc comments to these methods. Also I am thinking that we should deprecate the other methods since they are just wrong. @jrflat WDYT about deprecating?

Reviewers
Assignees
rksharma-owg rksharma-owg
Labels
risk: low confidence: 88.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 34.9% (LOW) · Higher = larger blast radius
34.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 88.1% · Lower = rushed or shallow review
88.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 4.1% · Safe to merge
4.1%