apple/swift-nio
59.7
Adequate · 27 September 2026
102.4k
lines of production code
Swift
with C
4
measurements over time
What this system is
SwiftNIO is a high-performance, asynchronous, non-blocking networking framework for Swift that provides low-level primitives for TCP, UDP, and HTTP/1.1 communication. It features a modern Swift Concurrency integration via NIOAsyncChannel and async sequences, alongside a comprehensive asynchronous file system abstraction in NIOFileSystem. The system includes extensive cross-platform support for Linux, macOS, Windows, and FreeBSD, with robust tooling for performance benchmarking, memory allocation tracking, and integration testing.
How it got here
2017–2018 — Swift 6.1 modernization and protocol expansion
30 changes.
This period focused on restructuring SwiftNIO for Swift 6.1 compatibility, introducing modular architecture and modern concurrency primitives like NIOLock and NIOAtomic. It significantly expanded protocol support by adding robust HTTP/1.1 validation, TLS negotiation features such as ALPN and SNI, and comprehensive WebSocket handling with typed upgraders. The work also included extensive platform-specific C shims for Linux and Darwin, alongside new sample applications and rigorous integration testing for performance and security.
2019–2021 — Swift Concurrency and modularization
25 changes.
The project expanded its Swift Concurrency support by introducing async/await APIs, dedicated testing primitives, and comprehensive sample applications for HTTP, WebSocket, and UDP protocols. Concurrently, the codebase underwent significant structural refactoring, splitting core modules like NIOCore and NIOPosix into smaller, maintainable units while enhancing cross-platform compatibility and test coverage.
2022–2026 — Swift Concurrency and File System integration
27 changes.
This period focused on bridging SwiftNIO with modern Swift Concurrency by introducing NIOAsyncChannel and async sequence producers for structured networking. It also established the internal infrastructure and public API for a new asynchronous file system module, \_NIOFileSystem, while adding comprehensive benchmarks and testing to validate these new concurrency primitives.
Features
Add CNIODarwin shim for sendmmsg/recvmmsg and cmsghdr utilities
Introduces the CNIODarwin header providing a shim implementation of sendmmsg (with recvmmsg stubbing) for Darwin platforms, along with helper functions for cmsghdr manipulation and constants for VSOCK and ECN support, enabling cross-platform socket messaging compatibility.
Sources/CNIODarwin/include · high confidence
Add Darwin-specific C shim for socket control and message operations
Introduces a new C shim file in the CNIODarwin module that provides cross-platform compatibility wrappers for socket operations. This includes a sendmmsg implementation for sending multiple datagrams, stubs for cmsghdr manipulation (CMSG\_FIRSTHDR, CMSG\_NXTHDR, CMSG\_DATA, CMSG\_LEN, CMSG\_SPACE), and exposes specific constants for IP Type of Service (ECN) flags, IPv6 packet info, and VSOCK ioctl commands. The recvmmsg function is explicitly marked as unimplemented on Darwin to prevent runtime errors.
Sources/CNIODarwin · high confidence
Add HTTP/1 client example application
A new sample application, NIOHTTP1Client, has been added to demonstrate a simple HTTP/1 echo client. Users can now run this example to send a basic HTTP GET request to a server and receive the echoed response, supporting connections via IP (with configurable host and port) or Unix domain sockets.
Sources/NIOHTTP1Client · high confidence
Add NIOCore performance benchmarks for async channels, promise waits, and address envelopes
The NIOCoreBenchmarks module now includes new performance tests for creating NIOAsyncChannel instances, waiting on promise futures (to detect memory leaks), and processing AddressedEnvelope messages with and without metadata through channel pipelines. These benchmarks help track performance regressions and memory usage in core NIO operations.
Benchmarks/Benchmarks/NIOCoreBenchmarks · high confidence
Add NIOEchoClient example application
Introduces a new sample application, NIOEchoClient, which demonstrates how to build a TCP echo client using SwiftNIO. The application supports connecting to servers via IPv4/IPv6, Unix domain sockets, and VSOCK, allowing users to test basic client-server communication patterns.
Sources/NIOEchoClient · high confidence
Add NIOFileSystem usage snippet
A new code snippet (NIOFileSystemTour.swift) has been added to demonstrate how to use the NIOFileSystem library. The example covers common file system operations such as inspecting file info, reading file contents with size limits, writing to files, listing directory contents, copying and removing items, and handling symbolic links and extended attributes.
Snippets · high confidence
Add NIOPosix performance benchmarks for TCP, UDP, and EventLoop scheduling
The NIOPosixBenchmarks module now includes comprehensive performance tests for core networking and concurrency primitives. Users can benchmark TCP echo throughput (both legacy and NIOAsyncChannel implementations), UDP echo performance (including packet info variants), and EventLoop scheduling overheads such as task scheduling, callback scheduling, and isolated event loop transitions. These benchmarks measure metrics like wall-clock time, context switches, and memory allocations to help track performance regressions or improvements in the underlying I/O and concurrency layers.
Benchmarks/Benchmarks/NIOPosixBenchmarks · high confidence
Add NIOWebSocketServer sample application
A new sample application demonstrating a WebSocket server has been added to the Sources/NIOWebSocketServer directory. The server binds to localhost on port 8888 by default (configurable via command-line arguments) and handles HTTP upgrades to WebSocket connections. It responds to specific WebSocket opcodes: it replies to 'ping' frames with 'pong' frames, closes connections upon receiving 'connectionClose' frames, and prints 'text' frames to the console, while ignoring other message types. The implementation uses Swift Concurrency and the NIOAsyncChannel API.
(repo-wide) · high confidence
Add UDP Echo Client sample application
Introduces a new sample application, NIOUDPEchoClient, that demonstrates a simple UDP echo client. The client sends a single line to a UDP echo server and waits for a response, supporting command-line arguments to specify the server host, server port, and local listening port. It also supports a \--connect\ flag for connected datagram sockets and can target Unix domain sockets.
Sources/NIOUDPEchoClient · high confidence
Add UDP multicast chat example
Introduces a new \NIOMulticastChat\ example application that demonstrates UDP multicast communication. The app allows users to join a multicast group (224.1.0.26:7654) to broadcast and receive chat messages, with support for specifying a network interface. It includes platform-specific handling for Android API 24+ availability and utilizes \NIONetworkDevice\ for interface enumeration.
Sources/NIOMulticastChat · high confidence
Add WebSocket client example application
A new sample application, NIOWebSocketClient, has been added to demonstrate how to establish a WebSocket connection using Swift Concurrency. The example performs an HTTP-to-WebSocket upgrade, sends a ping frame, and handles incoming text and pong frames, providing a concrete reference for users implementing async WebSocket clients.
Sources/NIOWebSocketClient · high confidence
Add async TCP echo server and client examples
New sample applications (NIOTCPEchoServer and NIOTCPEchoClient) are added to demonstrate using the async NIO APIs. The server listens on localhost:8765, wraps channels in NIOAsyncChannel, and handles each incoming connection in a separate task to echo back received strings. The client connects to the same server, sends multiple messages concurrently using a task group, and prints the responses.
Sources/NIOTCPEchoServer · high confidence
Add low-level Linux system call shims and liburing support
This change introduces new C source files (shim.c and liburing\_shims.c) in the CNIOLinux module to provide safe wrappers for various Linux-specific system calls and constants. It adds support for io\_uring via CNIOLinux\_io\_uring\_set\_link\_flag, exposes UDP segmentation (UDP\_SEGMENT) and UDP Generic Receive Offload (UDP\_GRO) detection capabilities, and implements wrappers for socket options like SO\_TIMESTAMP and SO\_RCVTIMEO. Additionally, it provides shims for message vector operations (sendmmsg/recvmmsg), thread affinity (pthread\_setaffinity\_np/getaffinity\_np with Android compatibility), and cmsghdr manipulation, ensuring consistent behavior across Linux and Android environments while working around specific toolchain issues like SR-12939.
Sources/CNIOLinux · high confidence
Added NIOFileSystem compatibility extensions for Foundation types
The NIOFSFoundationCompat module now includes extensions that bridge NIOFileSystem types with standard Foundation types. Users can initialize Foundation's \Data\ directly from a file path using a \FileSystemProtocol\ (with optional size limits), and convert \FileInfo.Timespec\ to \Date\ objects, simplifying file I/O and metadata handling in cross-platform Swift applications.
Sources/NIOFSFoundationCompat · high confidence
Added TokenBucket concurrency primitive for rate limiting
A new TokenBucket class has been added to the internal concurrency primitives to manage concurrent access using Swift Concurrency. This component implements a token bucket pattern similar to a semaphore, allowing a specified number of async closures to execute concurrently while suspending subsequent invocations until a token becomes available. It is designed to prevent resource exhaustion by limiting parallel operations, such as file system requests, to a configurable capacity.
Sources/NIOFS/Internal/Concurrency Primitives · high confidence
Expanded performance benchmark suite for SwiftNIO components
The NIOPerformanceTester tool now includes a significantly broader set of benchmarks to help users evaluate and optimize their application performance. New tests cover ByteBuffer operations (including view containment, iteration, and multi-integer read/write), channel pipeline management (instantiation and handler addition/removal), and data structure conversions (CircularBuffer to Array). The suite also adds benchmarks for concurrency primitives like NIOLock and NIOThreadPool submission, as well as scheduling tasks on EventLoops. Furthermore, it now measures the performance of NIOAsyncWriter and NIOAsyncSequenceProducer, deadline handling, and network protocols including TCP throughput, UDP datagrams, and WebSocket frame encoding/decoding.
Sources/NIOPerformanceTester · high confidence
Extracted PriorityQueue and added Heap and TinyArray data structures
The \_NIODataStructures module now includes a new PriorityQueue type backed by a Heap implementation, along with a Heap struct for managing ordered elements and a \_TinyArray optimized for storing zero or one element without heap allocation. These additions provide efficient priority queue functionality and specialized array handling within the library.
_Sources/\NIODataStructures · high confidence
Initial implementation of cross-platform system call wrappers for NIOFileSystem
This change introduces the low-level system call layer for the NIOFileSystem target, providing platform-specific wrappers for POSIX operations such as \stat\, \fstat\, \mkdir\, \rename\, and extended attribute management. It includes a \CInterop\ module to abstract platform types (e.g., \stat\ structures, directory pointers) across Darwin, Linux, Android, and Windows, and adds a \Mocking\ subsystem to enable syscall interception for testing. On Windows, it provides a compile-only compatibility shim with stubbed implementations to allow the NIOFileSystem family to build, while also adding specific wrappers for \symlinkat\, \renameatx\_np\, and \unlinkat\.
Sources/NIOFS/Internal/System Calls · high confidence
Integration test harness now hooks malloc\_zone functions and tracks file descriptors
The allocation-counter test framework on Darwin now intercepts the full set of malloc\zone\\* APIs (including malloc\_zone\_malloc, calloc, valloc, realloc, and memalign) in addition to standard libc allocation functions, ensuring more comprehensive memory usage tracking. The harness also extends its scope to track file descriptors by hooking socket, accept, and close calls, allowing tests to monitor resource usage beyond just memory allocations.
IntegrationTests/allocation-counter-tests-framework/template/HookedFunctionsDoHook/Sources/HookedFunctions · high confidence
Introduce CNIOWindows module with BSD socket and control message shims
The CNIOWindows module now provides a unified C header and module map that expose BSD socket APIs (send, recv, sendto, recvfrom, setsockopt, getsockopt) and control message helpers (CMSG\_DATA, CMSG\FIRSTHDR, etc.) via a CNIOWindows\ prefix, along with ssize\_t/socklen\_t compatibility, errno accessors, and stubs for sendmmsg/recvmmsg. This enables Swift code on Windows to call standard POSIX-style networking functions and handle ancillary data consistently with Unix platforms.
Sources/CNIOWindows/include · high confidence
Introduce NIOAsyncChannel for structured concurrency networking
SwiftNIO now provides NIOAsyncChannel, a new API that wraps a NIO Channel to integrate safely with Swift Concurrency. This change introduces inbound messages as an AsyncSequence and outbound writes via a back-pressured writer, allowing developers to handle network I/O using async/await patterns. The implementation includes a Configuration struct for tuning back-pressure strategies and outbound half-closure, along with dedicated test interfaces (TestSource and TestSink) to facilitate unit testing of the stream and writer components.
Sources/NIOCore/AsyncChannel · high confidence
Introduce NIOFileSystem with buffered I/O and convenience file operations
This change adds the NIOFileSystem module to the Sources/NIOFS location, providing a new asynchronous file system abstraction for Swift. It introduces buffered reading and writing via \BufferedReader\ and \BufferedWriter\, which manage memory buffers to optimize file I/O performance. The update also adds convenience extensions for \Array\, \ArraySlice\, \ByteBuffer\, and \String\ to easily read file contents or write data to disk using the new \FileSystemProtocol\. Additionally, it includes a \ByteCount\ type for safe size representation with saturating arithmetic to prevent overflow, and \DirectoryEntries\ for asynchronously iterating over directory contents.
Sources/NIOFS · high confidence
Introduce \_NIOFileSystem module with buffered I/O and convenience extensions
The new \_NIOFileSystem module adds a high-level, async file system API for Swift. It introduces \BufferedReader\ and \BufferedWriter\ for efficient, buffered streaming of file data, and provides \ByteCount\ with saturating arithmetic to prevent overflow when converting between units like kilobytes and gibibytes. Convenience extensions are added to \Array\, \ArraySlice\, \ByteBuffer\, \String\, and \Sequence\ types to simplify reading file contents into memory or writing data to files. Additionally, \DirectoryEntries\ and \FileChunks\ provide async sequences for iterating over directory contents and reading files in chunks, respectively.
_Sources/\NIOFileSystem · high confidence
Introduce internal NIOFileSystem implementation components
This change adds the internal implementation layer for the NIOFileSystem library, introducing core infrastructure such as \SystemFileHandle\ for managing file descriptors, \BufferedStream\ and \BufferedOrAnyStream\ for asynchronous data handling, and utilities for parallel directory operations like \ParallelDirCopy\ and \ParallelRemoval\. It also includes platform-specific compatibility helpers, such as \String+UnsafeUninitializedCapacity.swift\ for backporting Swift 5.4 features to older macOS versions, and cancellation utilities to support testing and robust teardown.
Sources/NIOFS/Internal · high confidence
Introduce internal \_NIOFileSystem module with core file system primitives
This change adds the internal \\_NIOFileSystem\ module to the SwiftNIO project, providing the foundational building blocks for a new file system API. The implementation includes \SystemFileHandle\ for managing low-level file descriptors and materialization strategies (rename or link), \BufferedStream\ and \BufferedOrAnyStream\ for handling asynchronous data sequences with backpressure, and utilities for parallel directory operations such as \ParallelDirCopy\ and \ParallelRemoval\. It also introduces helper types like \Cancellation\ for masking cancellation during critical operations and \String\ extensions for safe capacity initialization, establishing the internal infrastructure required for the upcoming high-level file system features.
_Sources/\NIOFileSystem/Internal · high confidence
Introduce low-level system call wrappers and platform compatibility shims for \_NIOFileSystem
The \_NIOFileSystem module now includes a new internal layer of low-level system call wrappers (such as \stat\, \mkdir\, \rename\, and extended attribute operations) and platform-specific compatibility shims. This change adds cross-platform type aliases and constants to unify behavior across Darwin, Linux, Android, and Windows, and introduces a syscall mocking infrastructure to support testing. On Windows, the implementation provides compile-only stubs for POSIX functions to allow the NIOFileSystem targets to build, with real Win32 mappings deferred to future updates.
_Sources/\NIOFileSystem/Internal/System Calls · high confidence
Introduce stackdiff tool for analyzing and comparing memory allocation stacks
The new \stackdiff\ tool in \dev/stackdiff\ enables developers to load, inspect, and diff memory allocation stacks from profiling data. It supports parsing output from Heaptrack, DTrace, and bpftrace via dedicated parsers, and provides three commands: \dump\ to display aggregated allocation stacks, \diff\ to compare two profiling files and highlight unique or changed allocations, and \merge\ to align similar stacks across two files using Levenshtein similarity scoring. The tool allows filtering by minimum allocation count, stack depth, and substring, and formats output to show allocation deltas and common stack prefixes.
dev/stackdiff · high confidence
Introduces NIOAsyncSequenceProducer, NIOAsyncWriter, and NIOThrowingAsyncSequenceProducer for Swift Concurrency bridging
This change adds new types to bridge between Swift Concurrency and synchronous code. NIOAsyncSequenceProducer and its throwing variant allow producing AsyncSequences from synchronous sources with configurable back-pressure strategies (such as HighLowWatermark). NIOAsyncWriter provides a mechanism to yield elements from async tasks into a synchronous consumer, supporting flow control via writability settings. These additions enable safer and more efficient integration of legacy synchronous APIs with modern async/await code.
Sources/NIOCore/AsyncSequences · high confidence
NIOCore restructured into modular source files with new datagram and async APIs
The NIOCore module has been reorganized into distinct source files (e.g., AddressedEnvelope, AsyncAwaitSupport, ByteBuffer-core) to improve maintainability. This change introduces the AddressedEnvelope type for handling UDP datagram metadata, adds async bridging methods like getAbandoningOnCancel() for EventLoopFuture, and expands ByteBuffer with new capabilities including hex dump formats, binary-encoded length prefixes, and inline array reading.
Sources/NIOCore · high confidence
NIOEchoServer now supports Unix domain sockets and VSOCK bindings
The NIOEchoServer sample application has been updated to accept command-line arguments that allow binding to Unix domain sockets and VSOCK addresses, in addition to the existing IP-based binding. Users can now start the server on a specific Unix socket path (e.g., \swift run NIOEchoServer /path/to/socket\) or a VSOCK context ID and port (e.g., \swift run NIOEchoServer 3 9999\), providing greater flexibility for local and virtualized network communication scenarios.
Sources/NIOEchoServer · high confidence
NIOHTTP1Server sample app adds dynamic endpoints and Unix socket support
The NIOHTTP1Server example application now includes a comprehensive set of dynamic endpoints for testing, such as /dynamic/echo, /dynamic/trailers, and /dynamic/client-ip, alongside existing static file serving via /sendfile and /fileio. It also supports binding to a Unix domain socket via command-line argument and respects HTTP keep-alive settings in responses.
Sources/NIOHTTP1Server · high confidence
New ALPN, SNI, and TLS event handlers for pipeline negotiation
This update introduces new channel handlers and types in NIOTLS to support modern TLS negotiation patterns. It adds \ApplicationProtocolNegotiationHandler\ and its typed counterpart \NIOTypedApplicationProtocolNegotiationHandler\ to manage ALPN negotiation, allowing users to reconfigure the channel pipeline based on the negotiated protocol or fall back to a default. It also introduces \SNIHandler\ to parse the Server Name Indication from the TLS Client Hello, enabling virtual-host-based pipeline configuration. Additionally, a new \TLSUserEvent\ enum is added to standardize TLS lifecycle events (handshake and shutdown completion) across implementations, and a \ProtocolNegotiationHandlerStateMachine\ provides the underlying state management for these handlers.
Sources/NIOTLS · high confidence
New CI and benchmarking scripts for SwiftNIO
The repository now includes a suite of new shell and Ruby scripts in the \scripts/\ directory to support continuous integration, benchmarking, and SDK management. These additions include \check-matrix-job.sh\ and \check-matrix-job.ps1\ for handling Swift version-specific command overrides in CI, \check\_benchmark\_thresholds.sh\ for validating performance regressions, and \analyze\_performance\_results.rb\ for comparing benchmark metrics. SDK management is supported by \install\_swift\_sdk.sh\, \install\_android\_ndk.sh\, and dedicated build wrappers for Android (\swift-build-with-android-sdk.sh\) and WebAssembly (\swift-build-with-wasm-sdk.sh\). Additional utilities include \generate\_matrix.sh\ for CI matrix generation, \cmake-build.sh\ for Ninja-based builds, \update-cmake-lists.sh\ for CMake source list maintenance, and \nio-diagnose\ for runtime diagnostics.
scripts · high confidence
New Foundation compatibility modules for ByteBuffer and FileSystem integration
This change introduces two new compatibility modules: \NIOFoundationEssentialsCompat\ and \\_NIOFileSystemFoundationCompat\. The former provides \ByteBuffer\ extensions for seamless conversion to and from Foundation \Data\ and \String\ types, including optimized byte-transfer strategies and JSON encoding/decoding support via \Codable\. The latter adds convenience initializers to read file contents directly into \Data\ objects using the \\_NIOFileSystem\ API, and provides conversion helpers between \FileInfo.Timespec\ and Foundation \Date\ objects, bridging the new file system layer with standard Foundation types.
_Sources/\NIOFileSystemFoundationCompat · high confidence
New allocation counter test framework with parallel execution support
The integration test suite now includes a new allocation counter test framework located in IntegrationTests/allocation-counter-tests-framework. This framework introduces a shell-based build system (run-allocation-counter.sh) that dynamically generates Swift Package Manifests to test allocation counting across multiple targets and platforms (macOS, iOS, watchOS, tvOS). It supports shared files between test modules and enables parallel execution of integration tests, allowing developers to verify memory allocation behaviors in a more comprehensive and faster manner.
IntegrationTests/allocation-counter-tests-framework · high confidence
New async-safe testing primitives: NIOAsyncTestingChannel and NIOAsyncTestingEventLoop
SwiftNIO now provides \NIOAsyncTestingChannel\ and \NIOAsyncTestingEventLoop\ as thread-safe, concurrency-aware alternatives to the existing \EmbeddedChannel\ and \EmbeddedEventLoop\. These new types are designed for use in Swift concurrency contexts, allowing tests to safely interact with embedded channels and event loops from multiple threads or async contexts without the thread-safety restrictions of the legacy embedded types. \NIOAsyncTestingEventLoop\ supports controllable time advancement and safe task scheduling, while \NIOAsyncTestingChannel\ provides fine-grained control over inbound and outbound events for unit testing pipelines.
Sources/NIOEmbedded · high confidence
New async/await HTTP client demo using Swift Concurrency
The NIOAsyncAwaitDemo now provides a complete example of an HTTP client built with Swift's async/await concurrency model. It introduces an AsyncChannelIO wrapper that exposes channel operations as async functions, allowing users to send requests and receive responses without manual promise handling. The demo includes a RequestResponseHandler to manage pipelined requests and responses, and a main entry point that demonstrates connecting to an HTTP server, sending multiple requests concurrently, and gracefully shutting down the event loop group, all guarded by availability checks for macOS 10.15, iOS 13, tvOS 13, and watchOS 6.
Sources/NIOAsyncAwaitDemo · high confidence
New development and debugging tooling scripts
The \dev\ directory now includes a suite of new scripts to aid in development, testing, and debugging. These include \alloc-limits-from-test-output\ for parsing test output into allocation limits (with JSON mode support), \lldb-smoker\ for running LLDB smoke tests using NIO, \make-single-file-spm\ for creating single-file Swift Package Manager projects, and various DTrace/bpftrace scripts (\malloc-aggregation.d\, \malloc-aggregation.bt\, \boxed-existentials.d\, \stackdiff-dtrace.py\) for debugging memory allocations. Additionally, \generate-bytebuffer-multi-int.sh\ is added to generate ByteBuffer multi-integer methods, \update-integration-test-thresholds.sh\ and \thresholds-from-benchmark-output.sh\ automate threshold updates from CI, and \git.commit.template\ provides a standardized commit message format.
dev · high confidence
New test utilities: ByteToMessageDecoderVerifier, EventCounterHandler, ManualTaskExecutor, and NIOHTTP1TestServer
The NIOTestUtils module now includes four new helpers to simplify testing SwiftNIO applications. ByteToMessageDecoderVerifier allows unit tests to verify ByteToMessageDecoder implementations by feeding inputs and checking outputs. EventCounterHandler tracks and validates channel pipeline events (like channelActive, channelRead) to ensure correct handler behavior. ManualTaskExecutor provides a deterministic way to control task execution in structured concurrency tests, enabling synchronous processing of enqueued jobs. NIOHTTP1TestServer offers a single-request HTTP/1 server for testing client implementations, providing visibility into received requests and control over responses.
Sources/NIOTestUtils · high confidence
New typed WebSocket upgraders and frame aggregation support
This release introduces \NIOWebSocketClientUpgrader\ and \NIOWebSocketServerUpgrader\ to handle the HTTP-to-WebSocket upgrade handshake, allowing users to configure the maximum frame size and enable automatic protocol error handling. It also adds \NIOTypedWebSocketClientUpgrader\ and \NIOTypedWebSocketServerUpgrader\ for typed pipeline integration, and includes \NIOWebSocketFrameAggregator\ to automatically reassemble fragmented WebSocket frames into complete messages for easier consumption.
Sources/NIOWebSocket · high confidence
Unified CNIOLinux umbrella header and liburing integration
The CNIOLinux module now exposes a single umbrella header (CNIOLinux.h) that aggregates standard Linux system headers (poll, epoll, socket, stat, etc.) and conditionally includes kernel-specific headers like linux/udp.h and linux/mptcp.h, providing a consistent interface for Swift code. It also introduces C shims for multi-message socket operations (sendmmsg/recvmmsg), cmsghdr manipulation, thread naming/affinity, and file time constants, while adding runtime checks for UDP segment and GRO support. Additionally, a new liburing\_nio.h header bridges the liburing library when SWIFTNIO\_USE\_IO\_URING is enabled, exposing io\_uring link flags and POLLRDHUP support.
Sources/CNIOLinux/include · high confidence
Architecture
NIOPosix restructured into modular source files with CNIOPosix C bindings
The NIOPosix module has been reorganized from a single large source file into a modular structure, introducing a new CNIOPosix library for C-level event loop ID management and splitting BSD socket APIs into platform-specific Swift files (BSDSocketAPICommon, BSDSocketAPIPosix, BSDSocketAPIWindows). This change improves maintainability and cross-platform support by separating POSIX and Windows socket implementations, while adding new files for base socket handling, channel lifecycle management, socket options, and bootstrap configurations.
Sources/NIOPosix · high confidence
Behavioural changes
Add OpenBSD support and fix SHA-1 portability for Windows
The library now supports OpenBSD by introducing a new CNIOOpenBSD module that provides C shims for platform-specific APIs such as sendmmsg/recvmmsg, pthread naming, and socket options. Additionally, the SHA-1 implementation in CNIOSHA1 has been updated to ensure the BYTE\_ORDER macro is defined on Windows, resolving compilation issues on that platform.
Sources/CNIOSHA1 · high confidence
Adds FreeBSD compatibility shim for network functions
Introduces a new C shim layer in Sources/CNIOFreeBSD that wraps standard BSD socket functions (inet\_ntop, inet\_pton) and includes a workaround for a Darwin toolchain bug. This enables the NIOCore target to compile and function correctly on FreeBSD by providing the necessary low-level networking bindings.
Sources/CNIOFreeBSD · high confidence
CNIOAtomics introduces macro-generated atomic operations for C and C++ interop
The CNIOAtomics module now provides a unified C API for atomic operations, generated via the DECLARE\_ATOMIC\_OPERATIONS macro. This change introduces two distinct implementation strategies: a standard C11 approach using \_Atomic types (catmc\_nio\atomic\\*) for stack-allocated storage, and a legacy heap-based approach (catmc\atomic\\*) for compatibility. The API supports a wide range of integer types, including standard sizes (int, long, long long), fixed-width types (int\_least8\_t through int\_least64\_t), and pointer-sized integers (intptr\_t, uintptr\_t). This restructuring improves C++ interoperability by using extern "C" linkage and standard C11 atomics, replacing older compatibility hacks.
Sources/CNIOAtomics · high confidence
CNIOSHA1 header updated for C++ compatibility and portability
The CNIOSHA1 header now supports C++ compilation by wrapping declarations in extern "C" and defining the \_\_min\_size macro inline. It also ensures BYTE\_ORDER is defined and includes sys/endian.h on Android to improve portability, while prefixing all symbols with 'c\nio\' to avoid namespace collisions.
Sources/CNIOSHA1/include · high confidence
Concurrency helpers refactored with new types and deprecation of legacy APIs
The NIOConcurrencyHelpers module has been restructured to introduce new, modern concurrency primitives while deprecating older ones. The legacy \Lock\ class is now deprecated in favor of the new \NIOLock\ struct, which uses tail-allocation via \ManagedBuffer\ for improved performance and memory efficiency. Similarly, \UnsafeEmbeddedAtomic\ and \Atomic\ are deprecated in favor of the new \NIOAtomic\ protocol and \NIOAtomicPrimitive\ extensions, which provide a more robust and type-safe interface for atomic operations. A new \NIOLockedValueBox\ struct is introduced to simplify locked access to values, and \ConditionLock\ has been updated to use \NIOLock\ internally. These changes aim to improve performance, safety, and ease of use for developers working with concurrency in SwiftNIO.
Sources/NIOConcurrencyHelpers · high confidence
Concurrency-safe token bucket implementation for \_NIOFileSystem
The internal concurrency primitives for \_NIOFileSystem now include a TokenBucket class that manages concurrent access using Swift Concurrency primitives and NIOLock. This implementation avoids holding locks over continuations to prevent potential runtime issues, ensuring that async operations wait efficiently for available tokens without risking deadlocks or runtime bugs.
_Sources/\NIOFileSystem/Internal/Concurrency Primitives · high confidence
Deprecate unintentionally public Base64 APIs
The public String initializers and methods for Base64 encoding and decoding (such as \init(base64Encoding:)\ and \base64Decoded()\) are now marked as deprecated with a message indicating they were unintentionally made public. Users should migrate to the internal \\_base64Encoding\ and \\_base64Decoded\ APIs or use Foundation's Base64 support, as these public entry points are no longer intended for external use.
_Sources/\NIOBase64 · high confidence
Deprecation of NIOFileSystem module in favor of \_NIOFileSystem
The NIOFileSystem module is now marked as deprecated and should not be used. It was created in error and incorrectly implies API stability. Users currently importing NIOFileSystem should migrate to \_NIOFileSystem, which exposes the same API but is the intended internal module. The NIOFileSystem module now re-exports \_NIOFileSystem and includes documentation warning users to switch.
Sources/NIOFileSystem · high confidence
HTTP parser updated to LLHTTP 9.3.0
The CNIOLLHTTP module has been updated to version 9.3.0 of the llhttp library. This change brings the latest parsing logic and protocol support from the upstream nodejs/llhttp project, ensuring the HTTP parser remains current with standard compliance and performance improvements.
Sources/CNIOLLHTTP · high confidence
Integration test framework adds file descriptor leak tracking
The allocation-counter test framework now tracks open file descriptors to detect leaks. This change introduces an atomic counter module with FD tracking functions (begin\_tracking\_fds, track\_open\_fd, track\_closed\_fd, stop\_tracking\_fds) and updates the Swift scaffolding to report leaked FDs alongside allocation metrics. Bootstrap templates are provided for both hooked and non-hooked modes, with the hooked mode intercepting socket/accept/close calls to monitor FD lifecycle.
IntegrationTests/allocation-counter-tests-framework/template · high confidence
NIO library restructured to expose NIOPosix and NIOEmbedded
The NIO module has been refactored to act as a shell that re-exports NIOCore, NIOEmbedded, and NIOPosix. This change consolidates the public API surface, allowing users to import NIO to access functionality from these underlying libraries, while NIOEmbedded has been moved to its own library.
Sources/NIO · high confidence
New HTTP header validation and improved HTTP/1.1 framing behavior
NIOHTTP1 now includes new channel handlers (NIOHTTPRequestHeadersValidator and NIOHTTPResponseHeadersValidator) that validate outbound request and response headers against RFC 9110 and RFC 9112 specifications, rejecting invalid characters in header names, values, and URIs to prevent header injection and smuggling attacks. Additionally, the HTTP encoder now automatically strips Content-Length and Transfer-Encoding headers from responses that must not have a body (such as HEAD or 304 responses) and correctly adds Transfer-Encoding: chunked for HTTP/1.1 responses with bodies that lack explicit framing, ensuring well-formed wire output.
Sources/NIOHTTP1 · high confidence
New blocking wait utility and JSON serialization helpers in NIOFoundationCompat
NIOFoundationCompat now provides a \waitSpinningRunLoop()\ method on \EventLoopFuture\ that allows synchronous waiting by spinning the current thread's run loop, primarily intended for testing or bridging blocking and non-blocking code (with a deprecation warning recommending \get()\ in async contexts). Additionally, the module adds a \JSONSerialization.jsonObject(with:options:)\ convenience method to parse JSON directly from a \ByteBuffer\, and introduces an \Exports.swift\ file to re-export \NIOFoundationEssentialsCompat\.
Sources/NIOFoundationCompat · high confidence
New shell-based integration test framework with JUnit XML output
The integration test suite has been rewritten in Bash, introducing a plugin-based architecture that supports both standard console output and JUnit XML reporting via the new \--junit-xml\ flag. This change adds core test runner scripts (\run-tests.sh\, \run-single-test.sh\) and utility libraries (\test\_functions.sh\) that provide assertion helpers and an 'info' mode for verbose logging, enabling better debugging and CI integration for the SwiftNIO project.
IntegrationTests · high confidence
Restoration of \_NIOConcurrency module for backward compatibility
The \_NIOConcurrency module has been re-added to prevent breaking existing adopters, though its functionality has been migrated to NIOCore. This module now serves solely as a compatibility shim; users are advised to remove their dependencies on \_NIOConcurrency as it is scheduled for removal in the near future.
_Sources/\NIOConcurrency · high confidence
Standardized repository configuration and contributor privacy controls
The repository now enforces consistent code formatting via a new \.swift-format\ configuration and \.editorconfig\, and integrates with the Swift Package Index for documentation via \.spi.yml\. To support contributor privacy, a \.mailmap\ file unifies multiple email addresses for existing contributors, and a \.mailfilter\ file allows for the optional opt-out of PII in the \CONTRIBUTORS.txt\ list. Additionally, the repository-level \CODE\_OF\_CONDUCT.md\ has been removed in favor of the project-wide Swift Code of Conduct, and the \CONTRIBUTING.md\ guide has been updated to reflect the new formatting and testing workflows.
(repo-wide) · high confidence
Windows networking initialization and error handling improvements
This change ensures Windows-specific networking components initialize correctly and handle errors more robustly. It introduces a module constructor to automatically call WSAStartup, preventing potential socket errors due to uninitialized Winsock. Additionally, it adds shims for retrieving detailed error messages from Windows API calls using FormatMessage and ensures standard output is unbuffered for clearer logging.
Sources/CNIOWindows · high confidence
Test coverage
Add allocation count integration tests; Added comprehensive test suite for NIOFileSystem core components; Added comprehensive test suite for NIOPosix components; Added integration test to verify binaries do not link Foundation; Added integration tests for NIOFileSystem; Added integration tests for NIOLock crash behavior; Added integration tests for syscall wrapper error handling; Added test coverage for NIOFoundationCompat utilities; Added test coverage for NIOWebSocket components; Added test suite for NIOConcurrencyHelpers; Added test suite for NIOEmbedded testing utilities; Added test suites for NIOTestUtils components; Added tests for ALPN and SNI handlers; Added tests for AsyncChannel testing interfaces and core functionality; Added tests for NIO singletons; Added tests for NIOAsyncSequenceProducer, NIOAsyncWriter, and NIOThrowingAsyncSequenceProducer; Added unit tests for Base64 encoding and decoding; Added unit tests for Heap and PriorityQueue data structures; Expanded test coverage for NIOCore types and ByteBuffer operations; Expanded test coverage for NIOHTTP1 parsing, encoding, and upgrade logic; HTTP/1 integration test suite for NIOHTTP1Server; New allocation counting and performance integration tests for SwiftNIO resources.
Dependencies
SwiftNIO package restructured for Swift 6.1 with new external dependencies
The SwiftNIO package has been upgraded to Swift tools version 6.1 and restructured into a modular architecture, introducing new library products such as NIOCore, NIOPosix, NIOEmbedded, and NIOFoundationEssentialsCompat. This change replaces internal legacy modules with external dependencies, specifically adopting swift-atomics, swift-collections, and swift-system, while also adding a privacy manifest for Darwin platforms and enabling the experimental Lifetimes feature.
(dependencies) · high confidence
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.
Score
- CAI 46 → 60 (+13.6)
- Rubric changed (rubric-2026.08.15 → rubric-2026.09.15) — scores are not directly comparable.
Lenses
- Code Health 100 → 89 (-11.1)
- Architecture 69 → 97 (+28.2)
- Maturity 50 → 67 (+16.4)
- Readiness 35 → 74 (+38.9)
- Security 48 → 44 (-4.7)
- Event-Driven 79 (new)
Resolved (16)
- Dimension evaluation failed
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- High: security finding (details withheld)
- No automated tests
- No exposed public API
- No tests found
- Test reliability not included
- early-stage repository — too little history to judge knowledge freshness
- single-commit history — no usable git history window to measure hotspots
- single-maintainer — knowledge-concentration (bus factor) risk
New (998)
- Base64.decode (cognitive 16) (Sources/_NIOBase64/Base64.swift)
- BaseSocketChannel.flushNow (cognitive 33) (Sources/NIOPosix/BaseSocketChannel.swift)
- BaseSocketChannel.flushNow (cyclomatic 22) (Sources/NIOPosix/BaseSocketChannel.swift)
- BaseSocketChannel.readable0 (cognitive 23) (Sources/NIOPosix/BaseSocketChannel.swift)
- BaseStreamSocketChannel.close0 (cognitive 29) (Sources/NIOPosix/BaseStreamSocketChannel.swift)
- BaseStreamSocketChannel.readFromSocket (cognitive 18) (Sources/NIOPosix/BaseStreamSocketChannel.swift)
- BetterHTTPParser.didReceiveHeadersCompleteNotification (cognitive 18) (Sources/NIOHTTP1/HTTPDecoder.swift)
- BetterHTTPParser.didReceiveHeadersCompleteNotification (cyclomatic 17) (Sources/NIOHTTP1/HTTPDecoder.swift)
- ByteToMessageDecoderVerifier.verify (cognitive 41) (Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift)
- ByteToMessageDecoderVerifier.verify (cyclomatic 20) (Sources/NIOTestUtils/ByteToMessageDecoderVerifier.swift)
- ByteToMessageHandler.decodeLoop (cognitive 16) (Sources/NIOCore/Codec.swift)
- Change coupling clique: SelectableEventLoop.swift, SelectorEpoll.swift, SelectorKqueue.swift (Sources/NIOPosix/SelectableEventLoop.swift)
- Change coupling: BSDSocketAPIPosix.swift ↔ BSDSocketAPIWindows.swift (Sources/NIOPosix/BSDSocketAPIPosix.swift)
- Change coupling: BSDSocketAPIPosix.swift ↔ Socket.swift (Sources/NIOPosix/BSDSocketAPIPosix.swift)
- Change coupling: DeadChannel.swift ↔ SocketChannel.swift (Sources/NIOCore/DeadChannel.swift)
- Change coupling: Linux.swift ↔ System.swift (Sources/NIOPosix/Linux.swift)
- ClassTooLong: ByteBuffer (Sources/NIOCore/ByteBuffer-core.swift)
- ClassTooLong: ChannelPipeline (Sources/NIOCore/ChannelPipeline.swift)
- ClassTooLong: DatagramChannel (Sources/NIOPosix/SocketChannel.swift)
- ClassTooLong: FileSystem (Sources/NIOFS/FileSystem.swift)
- …and 978 more
Changes since last survey
- 25 commits — 18 feature/other, 7 fixes
By area
- Sources/NIOCore — 10 commits
- IntegrationTests/tests_04_performance — 2 commits
- Sources/NIOPosix — 2 commits
- Tests/NIOCoreTests — 2 commits
- scripts/install_swift_sdk.sh — 2 commits
- (root) — 1 commit
- Benchmarks/Thresholds — 1 commit
- Sources/CNIOWindows — 1 commit
- Sources/NIOFS — 1 commit
- Tests/NIOPosixTests — 1 commit
- Tests/NIOTestUtilsTests — 1 commit
- scripts/swift-build-with-android-sdk.sh — 1 commit
Notable commits
- fix: Fix Android Swift SDK installation in CI workflows (#3737)
- fix: Fix Integration Tests thresholds (#3732)
- fix: Fix new NoUseUnstructuredThrowingTask warnings (#3733)
- fix: Fix the Returns callout on DispatchQueue.asyncWithFuture (#3740)
- fix: Fix warnings: private setters cannot be referenced from an '@inlinable' function (#3719)
- fix: [Windows] Fix buffer sizing in System.enumerateDevices() (#3684)
- fix: fix(ci): fix static Linux SDK version discovery for main snapshots (#3726)
- change: Add API to get the result of an isolated ELF, if available (#3721)
- change: Add channel options for a vsock socket's local and remote addresses (#3689)
- change: Add socket option API for SO_REUSEPORT (#3741)
- change: Allow non-copyable ByteToMessageDecoders and typed throws (#3731)
- change: Android CI builds shouldn't link the stdlib statically (#3739)
- change: ELF.getAbandoningOnCancel() (#3722)
- change: Fix spelling of compatibility in RecvByteBufferAllocator (#3742)
- change: Housekeeping: replace repo-level CODE_OF_CONDUCT (#3751)
- change: Mark ByteBuffer._Storage's _capacity and _bytes @exclusivity(unchecked) (#3734)
- change: Name the documented arguments the way the declarations name them (#3698)
- change: Remove unused SelectorLifecycleState.closing (#3695)
- change: Simplify imports in SocketAddresses.swift (#3696)
- change: Translate ByteToMessageDecoderVerifierTest to Swift Testing (#3730)
- …and 5 more
Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
apple/swift-nio was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 27 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit feaf4ac57e27e411e83e88ee2f9b1789ddf08d0b — the exact code this score is about.
- Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-d00c643c3f66.