Commit Graph
171 Commits
Author SHA1 Message Date
Fabian Fett 6a6f7d7c33 Centralize UnsafeTransfer in NIOCore (#3492)
We have a number of copies of `UnsafeTransfer` and two copies of
`UnsafeMutableTransferBox` in our code base. Before introducing more of
those, lets centralize to just one using a `package` access modifier.
2026-02-03 10:27:30 +00:00
Si Beaumont 37ffc4b8d5 Add API to enable throwing in EmbeddedChannel.getOption and .setOption if channel is closed (#3495)
### Motivation:

Channels based on `BaseSocketChannel` throw in both `getOption` and
`setOption` if the channel has been closed, since the `setsockopt` will
fail. However, the current behavior of `EmbeddedChannel` is options
remain writable and readable on closed channels.

There are situations where we'd like to be able to model the runtime
behaviour of the real channel in tests, e.g. to test this fix:
https://github.com/apple/swift-nio-extras/pull/304.

### Modifications:

- Add API to enable throwing in `EmbeddedChannel.getOption` and
`.setOption` if channel is closed.
- Add a test for this new behavior.

### Result:

- New API to enable throwing in `EmbeddedChannel.getOption` and
`.setOption` if channel is closed.
- No observable change for existing users of `EmbeddedChannel`.
2026-01-27 12:06:55 +00:00
aryan-25 b0895c094d Update integration test allocation thresholds for nightly-main (#3465)
### Motivation:

From
https://github.com/apple/swift-nio/actions/runs/20197120190/job/57982705638
onwards, the Integration Test benchmark runs have been failing for
`Linux (nightly-main)` due to allocations for seven tests falling below
the defined thresholds.

### Modifications:

Updated thresholds for the tests where the number of allocations were
out-of-threshold (seven in total).

### Result:

The Integration Test run for `Linux (nightly-main)` no longer fails.
2025-12-17 17:14:42 +00:00
Rick Newton-Rogers 56724a2b6d NIOAsyncTestingChannel local/remote addrs on EmbeddedChannelCore (#3442)
### Motivation:

`NIOAsyncTestingChannel` stored its `localAddress` and `remoteAddress`
in a locked storage on itself for thread safety, however in doing so
left us open to bugs because a handler grabbing the addresses of the
context had no visibility of the values.

### Modifications:

Reach into `EmbeddedChannelCore` for the addresses instead of storing
them on the `NIOAsyncTestinghannel`. I also considered a delegate
approach where the `EmbeddedChannelCore` could offload the
responsibility for storing the values back to the
`NIOAsyncTestingChannel` but it was complicated and of questionable
value.

### Result:

* The correct address values are seen no matter how they are obtained.
* We probably take a performance hit locking the values in this way but
this is testing code so probably not the end of the world.
2025-11-11 15:08:15 +00:00
Fabian Fett 6c114e3c62 Update CI scripts for 6.2 (#3374)
Replaces: #3373
2025-09-19 13:55:48 +01:00
George Barnett 9b2642c21b Use path based deps in the alloc counter framework (#3355)
The alloc counter framework uses `url` based deps for local
dependencies. They should use `path` instead.
2025-08-22 11:14:33 +01:00
George BarnettandCory Benfield 664032bdd6 Wrap closures stored in the CallbackList (#3303)
Motivation:

The compiler is better at optimising closures wrapped in nominal types
than raw closures when used as generic parameters. CallbackList is used
a lot and stores an optional closure as well as on optional array of
closures. Wrapping these internally should save some allocations.

Modifications:

- Wrap the element stored in the `CallbackList`.

Result:

Fewer allocs

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-07-14 16:48:26 +00:00
Cory Benfield 70439feacd Widen the allocation limit on nightlies (#3280)
Nightly CI fails occasionally because the allocs on low-overhead lists
occasionally break 20. Give ourselves some breathing room here.
2025-07-01 11:45:13 -07:00
Cory Benfield c9e2ac115f Adjust for SendableMetatype (#3266)
Motivation

With the introduction of isolated conformances, it has become necessary
to start managing the use of metatypes for some of our protocols. In
general, we don't want to force the relevant protocols to only be
conformed in non-isolated forms. Instead, we just want to make the
specific APIs non-usable.

Modifications

- Add shims for SendableMetatype that only use it when it is available.
- Require SendableMetatype where needed, gated by @preconcurrency.

Result

We continue to be safe.
2025-06-13 09:12:25 +01:00
Rick Newton-Rogers 57658e12ff Drop Swift 5.9 (#3228)
Motivation:

Swift 5.9 is no longer supported, we should bump the tools version and
remove it from our CI.

Modifications:

* Bump the Swift tools version to Swift 5.10
* Remove Swift 5.9 jobs where appropriate in main.yml, pull_request.yml

Result:

Code reflects our support window.
2025-05-07 12:24:44 +00:00
Rick Newton-Rogers b8c446368d Add and enable Swift 6.1 workflows (#3196)
Add and enable Swift 6.1 workflows

### Motivation:

Swift 6.1 has been released, we should add it to our CI coverage.

### Modifications:

* Update `appe/swift-nio/scripts/generate_matrix.sh`
* Update reusable adopters of `swift_test_matrix.yml`
* Update end-user adopter workflows of `swift_test_matrix.yml`
  * Copy over test flags from Swift 6.0 jobs

### Result:

NIO tests against Swift 6.1 in CI and downstream repositories can
opt-in.

(Successful CI run with the workflows modified to use the changes on
this branch
https://github.com/apple/swift-nio/actions/runs/14400598096?pr=3196)
2025-04-11 13:45:49 +01:00
Gus Cairo 7d3204d232 Improve alloc tests failure messages (#3173)
This PR improves the messaging when tests fail so it's easier to
troubleshoot failures.
2025-04-03 15:23:41 +00:00
Rick Newton-Rogers 26d40ebbda Delete Thresholds/nightly-6.1 symlinks (#3133)
Following on from https://github.com/apple/swift-nio/pull/3126 delete
`Benchmarks/Thresholds/nightly-6.1` and
`IntegrationTests/tests_04_performance/Thresholds/nightly-6.1.json`
which is no longer needed now that the shared benchmarks workflow has
been updated.
2025-03-07 12:09:53 +00:00
Rick Newton-Rogers 517dccac42 rename nightly 6 1 to nightly next (#3126)
Use nightly_next as swift version

see https://github.com/apple/swift-nio/pull/3122

Motivation:
To not have to rename threshold directories when the nightly branch
changes.

Modifications:
* Use nightly_next as swift version in the matrix generation script
which
is picked up by the benchmark script.
* Move nightly-next thresholds and add legacy symlink

Result:

Benchmark thresholds will attempt to find directories named
nightly_next, not nightly_6_1.
2025-03-04 09:37:47 +00:00
Clinton NkwochaandGeorge Barnett b14012bb1a Improve flatScheduleTask (#3079)
Motivation:

As pointed out in #3071, the `flatScheduleTask` implementations can be
improved.

Modifications:

- Refactor the `flatScheduleTask` implementations to skip `flatMap`
calls, which avoids creating an extra promise.
- As there is now a lower number of allocations, reduce the necessary
thresholds for the allocation tests.

Result:

Reduction in the number of allocations in the package.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-22 16:26:51 +00:00
Rick Newton-Rogers 9336e1f259 more 6.0 nightly to 6.1 nightly CI changes (#3078)
### Motivation:

Some changes were missed in #3076, passing through parameters for the
new 6.1 version.

### Modifications:

Pass through more parameters, clean up misleading comments.

### Result:

6.1 nightly runs will be more like 6.0 nightly runs were
2025-01-22 13:38:02 +00:00
Cory BenfieldandGeorge Barnett e2bfe0875b Adopt optimized isolated path for SelectableEL (#3075)
Motivation:

Users of SelectableEventLoop deserve to have their code that uses the
isolated event loop view perform at least as well as the code that
doesn't.

Modifications:

- Adopt the extra protocol witnesses.
- Refactor out common code.

Result:

Better performance

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-21 16:36:41 +00:00
bf41ad1595 Improve HTTPHeaders description performance (#3063)
### Motivation:

As outlined in this
[issue](https://github.com/apple/swift-nio/issues/2930) by @weissi, the
current performance of calling `description` on `HTTPHeaders` is
undermined by the dynamism of Array.

### Modifications:

The proposed solution replaces the implementation of `description` to
iterate over the items and print them out manually. This provides a
faster solution since we bypass the cost of calling into `description`
of an Array.


### Result:

A more performant implementation of `HTTPHeaders` description.

---------

Co-authored-by: Johannes Weiss <johannesweiss@apple.com>
Co-authored-by: Cory Benfield <lukasa@apple.com>
2025-01-20 16:39:21 +00:00
Cory BenfieldandGeorge Barnett 77c1b79c6c Move Isolated EL operations to EL protocol (#3070)
Motivation

Right now the isolated view on the EventLoop has to implement its
interface in terms of UnsafeTransfer, because there are no non-Sendable
operations it can use.

That hurts us because we have to allocate an extra closure for all these
operations, making them slower than they need to be. This is unavoidable
in some contexts, but most EventLoops would be able to offer a fast-path
that avoids this extra allocation.

To achieve that, we need to move this logic into a customisation point
on the EventLoop protocol. Our fallback default implementation can be
the same as we do today.

Modifications

- Add customisation points for EventLoop for each of its operations that
has a protocol witness already.
- Add default implementations of these, using the implementation from
EventLoop.Isolated.

Results

No behavioural changes, but the code has moved.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
2025-01-20 14:06:21 +00:00
Cory Benfield 15a38aef06 Add allocation counter tests for isolated EL operations (#3068)
Motivation:

As with the ELF operations before them, the isolated EL operations
currently incur overhead above-and-beyond the overhead of their
non-isolated counterparts. That's not what we want to see. However,
before we "fix" them, we need to add regression testing to confirm our
fix actually worked.

Modifications:

- Add isolated variations of all current EL scheduling tests.
- Where isolated methods didn't have alloc counter tests, add new ones
for the non-isolated versions too.

Result:

More tests.
2025-01-17 10:31:53 +00:00
Cory Benfield 6ac01d1734 Clean up sendability in the bootstraps (#3051)
### Motivation:

The bootstraps are the next most obvious target for cleaning up
Sendability issues. These issues are mostly just missing annotations,
but there are a few places where we had actual latent threading bugs
that were missed. A lot more of the control flow is made more explicit
in this patch, and in general it should get a lot easier to be confident
that the code is correct.

### Modifications:

- Add necessary `@Sendable` annotations
- Clean up some incorrect `self` captures of bootstraps, which are not
`Sendable`, and which could lead to real threading bugs
- Make a few methods `static` to avoid needing to capture `self` at all.
- Make a few threading assumptions clear by using the isolated views or
the sync operations
- Add some missing `Sendable` constraints on interior generic functions.

### Result:

Better safety, better correctness in the bootstraps.
2025-01-14 20:49:33 +00:00
Cory Benfield e19202cb01 Avoid abstraction overheads on isolated ELF (#3055)
Motivation:

Unfortunately, closure composition is really expensive: closures that
capture closures always heap allocate. To make ELF.Isolated perform
well, then, we need to inline the method bodies directly.

Modifications:

- Add some isolated functions into ELF for enqueueing callbacks.
- Inline the implementation of the ELF methods into the isolated view.

Result:

Allocation counts match between isolated/nonisolated.
2025-01-13 20:31:22 +00:00
Cory Benfield 588523e7d6 Test allocations of isolated ELF views (#3054)
Motivation:

We've added isolated views onto EventLoopFutures. These are great, but
as initially implemented they add a bunch of overhead to the nonisolated
versions. That's not optimal, but before we change the code we should
make sure we have a benchmark baseline.

Modifications:

- Extend the test_future_lots_of_callbacks alloc test to add all the
callbacks that the isolated views have.
- Duplicate that test to one that adds isolated wrappers so we can
compare.

Result:

Two regression tests whose allocation counts should be equal, but
aren't.
2025-01-13 17:44:49 +00:00
Cory Benfield 2d72ada999 Get NIOEmbedded clean under strict concurrency (#3030)
Motivation:

NIOEmbedded is used all over NIO-land for testing various pieces of the
infrastructure, and so requires a substantial audit for strict
concurrency.

Modifications:

- Mark a few things Sendable.
- Fix the tests, which actually did have some nasty bugs

Result:

Sendable-clean NIOEmbedded
2024-12-17 09:49:06 +00:00
Cory Benfield 8126cba712 Avoid converting array holding existentials (#3006)
Motivation:

When converting an Array that holds existentials, it is necessary for
Swift to allocate a new Array and copy the elements into it, so that it
can fix up their existential boxes. We forced this to happen with taking
a `[ChannelHandler]` to `[ChannelHandler & Sendable]`, without rewriting
the other functions.

The result of that was that the other functions needed to convert the
channel handler types, causing extra allocations in this path.

Modifications:

Propagate the constraint down to the point where we iterate the Array.

Result:

Allocations reduced.
2024-11-28 11:30:54 +00:00
Peter Adams e1d0d21391 Correct allocation test script (#2956)
Motivation:

Unfortunately the current script has a bug meaning it can never fail.

Modifications:

Change bracketing for output search.

Result:

Allocation tests will flag when failing
2024-10-31 15:15:24 +00:00
Ayush Garg 7840b6b067 ChannelOption: Allow types to be accessed with leading dot syntax (#2816)
Motivation:

Since Swift 5.5 and [SE-0299](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md) it is possible to add static members to protocols which are discoverable through the shorthand dot syntax.
This change reduces type repetition and improves call-site legibility.

Modifications:

Added extensions for ChannelOption with static members where Self is bound to a concrete type.

Result:

ChannelOption types can be used with the leading dot syntax. For eg:

```
//before
.channelOption(ChannelOptions.explicitCongestionNotification, value: true)
.channelOption(ChannelOptions.socketOption(.so_reuseaddr), value: 1)

//after
.channelOption(.explicitCongestionNotification, value: true)
.channelOption(.socketOption(.so_reuseaddr), value: 1)
```
2024-07-30 15:19:59 +00:00
Franz Busch f17f7e5909 [CI] Add shellcheck and fix up warnings (#2809)
# Motivation

We have quite a lot of shell scripts in our repo and want to make sure that they all pass `shellcheck`.

# Modification

This PR adds a GH action workflow to the soundness script for `shellcheck` and fixes up all errors and warnings.

# Result

No more shell/bash discussions
2024-07-25 14:55:44 +00:00
Si Beaumont 55d4c49334 Better align shutdown semantics of testing event loops (#2800)
### Motivation:

The two testing event loops—`EmbeddedEventLoop` and `NIOAsyncTestingEventLoop`—have different semantics for outstanding work during shutdown, which are both different from the production `SelectableEventLoop`, specifically with newly scheduled tasks that result from running existing scheduled work at the time of shutdown.

There are three axes to consider:

1. Scheduled tasks that are at or past their deadline.
2. Scheduled tasks with a deadline in the future.
3. Newly scheduled work that result from either running or cancelling (1) and (2).

| | (1) | (2) | (3) |
|-|-|-|-|
| `SelectableEventLoop` | Run | Cancel | Quiesce over 1000 ticks, repeatedly run resulting (1) and cancel resulting (2) |
| `EmbeddedEventLoop` | Run | Cancel | Cancel resulting (1) and resulting (2) |
| `NIOAsyncTestingEventLoop` | Run | Run | Run resulting (1) and resulting (2) |

Note that `NIOAsyncTestingEventLoop` may never terminate because of this.

### Modifications:

This PR aligns `EmbeddedEventLoop` and `NIOTestingEventLoop` and makes them more similar to `SelectableEventLoop` and less surprising semantics.

### Result:

| | (1) | (2) | (3) |
|-|-|-|-|
| `SelectableEventLoop` | Run | Cancel | Quiesce over 1000 ticks, repeatedly run resulting (1) and cancel resulting (2) |
| `EmbeddedEventLoop` | Run | Cancel | Cancel resulting (1) and resulting (2) |
| `NIOAsyncTestingEventLoop` | Run | Cancel | Cancel resulting (1) and resulting (2) |

### Future work:

Given both the `EmbeddedEventLoop` and `NIOAsyncTestingEventLoop` are used in tests of NIO applications that run with `SelectableEventLoop` in production, it might be worth extending both to also support quiescing to give a more representative shutdown behaviour in tests.
2024-07-25 14:38:36 +00:00
Franz Busch c9756e1083 Adopt swift-format (#2794)
* Apply formatting

* Apply no block comments rule

* Apply OmitExplicitReturns

* Apple OnlyOneTrailingClosureArgument

* Apply NoAssignmentInExpressions

* Fix up DontRepeatTypeInStaticProperties lint errors

* Apply `OrderedImports`

* Apply `ReplaceForEachWithForLoop`

* format file

* Enable the formatting pipeline

* Adopt `AmbiguousTrailingClosureOverload`

* Fix license header

* Fix format check

* Fix `EndOfLineComment`

* Fix CI

* Adapt CI script to check if changes when running formatting

* Separate lint and format into to steps

* Fix format

* Adopt `UseEarlyExits`

* Revert "Adopt `UseEarlyExits`"

This reverts commit d1ac5bbe12.
2024-07-19 11:48:17 +02:00
George Barnett 980bd3e630 Disable warnings as errors on Swift 6 and main (#2793)
Motivation:

The Swift 6 compiler emits a number of warnings about sendability which
we haven't dealt with yet. The CI failing on warnings may mask other
compilation issues or test failures.

Modifications:

- Disable warnings as errors on Swift 6 and main

Result:

Swift 6 and main CI should pass
2024-07-18 12:10:50 +00:00
Johannes Weiss 7948ed2104 ChannelHandler: provide static (un)wrap(In|Out)bound(In|Out) (#2791) 2024-07-18 11:55:48 +01:00
Franz Busch 8a69bd9d88 [GHA] Cxx interoperability compatibility and integration tests check (#2790)
# Motivation

Another reusable check is to make sure that all library products of a package are successfully building when consumed from a module that has Cxx interoperability enabled. Another check that's missing is running the integration tests.

# Modification

This PR adds two new checks to the reusable workflow. One to check for Cxx interoperability compatibility and another one to run the integration tests. I also fixed a misalgined name for the nightly benchmarks.

# Result

This should be one of the last reusable workflow checks.
2024-07-16 01:22:04 -07:00
Franz Busch 5cc05490c4 [GHA] Unacceptable language check (#2766)
* [GHA] Unacceptable language check

# Motivation

Next up replacing part of our soundness script that checked for unacceptable language.

# Modification

This PR adds a new GH action that checks for unacceptable language.

# Result

One more script replaced

* PR review

* Change homepage link to repo
2024-07-09 07:56:26 +01:00
Gregor Milos (Grzegorz Miłoś) fc63f0cf4e Fix memory allocations counters on macOS. (#2673)
Motivation:

Allocation counters are broken on macOS as described [here](https://github.com/apple/swift-nio/issues/2672). This PR fixes it.

Modifications:

`AtomicCounter` library is made `.dynamic`. This deduplicates the two (static) copies that used to exist. One embedded in the main binary, and the other in `HookedFunctions` dylib. This deplication fixes the issue, because there is just one copy of the counters in the process address space.

Result:

All the tests counting allocations and related statistics work on macOS.
2024-03-06 14:46:50 +00:00
Gustavo Cairo 0c648c91c6 Fix broken tests (#2621)
* Update swift-tools-version to 5.7 in integration tests

* Fix flaky test

* Add missing AtomicCounter dependency in generated Package.swift

* Update swift-tools-version in integration test helper Swift projects

* Make test clearer

* Don't run MTELG integration test on Swift 5.11+

It hasn't been properly tested
2024-01-08 10:02:09 +00:00
Alastair Houghton fc6e3c0eef Changes to support building with Musl (#2595)
* Changes to support building with Musl

Define `_GNU_SOURCE` in the `Package.swift` rather than in `shim.c`
(this is required because `_GNU_SOURCE` affects modular headers).

Add an import for Musl to IO.swift.

Add code to disable `SIGPIPE` to `SocketProtocols.swift`.

Remove types from a pile of functions in `System.swift`; Swift will
use the correct type automatically (except in cases where there are
multiple versions of a function, e.g. `ioctl()`, in which case we
need to be explicit which one we mean).

* Fix some test failures caused by failing to define `_GNU_SOURCE`.

A couple of the integration tests grab code and build it outside of the
normal `Package.swift`, so they needed fixing to define `_GNU_SOURCE`
themselves.
2023-11-29 17:27:13 +00:00
Rick Newton-Rogers 67553a7d6d Bump minimum Swift version to 5.7 (#2524)
* Bump minimum Swift version to 5.7

Motivation:

Now that Swift 5.9 is GM we should update the supported versions and
remove 5.6

Modifications:

* Update `Package.swift`
* Remove `#if swift(>=5.7)` guards
* Delete the 5.6 docker compose file and make a 5.10 one
* Update integration test script
* Update docs

Result:

Remove support for Swift 5.6, add 5.10

* fix indentation issues

* 5.9 docker image use release image
2023-10-02 11:38:07 +01:00
Franz Busch 4c6083f6a3 Fix 5.9 and nightly allocation limits (#2485) (#2487)
# Motivation
Our 5.9 and nightly CI has been failing for some time now due to flaky allocation tests.

# Modification
This PR slightly changes some shared infra for how we ran some of our allocation tests. We are now waiting for the client and server channel to close so that allocations are more stable.

# Results
Green CI again
2023-07-31 09:30:37 +01:00
Franz Busch e77a948e57 Fix 5.9 and nightly allocation limits (#2485)
# Motivation
Our 5.9 and nightly CI has been failing for some time now due to flaky allocation tests.

# Modification
This PR slightly changes some shared infra for how we ran some of our allocation tests. We are now waiting for the client and server channel to close so that allocations are more stable.

# Results
Green CI again
2023-07-28 11:01:47 -07:00
finagolfin 231902a295 Correct a few Musl additions from #2449 for Android, plus error if libc not found (#2451)
Motivation

Fix build errors on Android

Modifications

- Fix previous Musl modifications that assumed Glibc wasn't imported on Android
- Add errors for all libc imports, so new platform ports error out early

Result

NIO builds natively on Android again, with all the same tests passing
2023-06-26 02:52:18 -07:00
Franz Busch e865f6163f Use #if canImport(Darwin) where possible (#2446) 2023-06-22 10:12:01 +01:00
Cory Benfield fd35cd9e52 Extend the integration test harness to track FDs (#2411)
* Extend the integration test harness to track FDs

Motivation

This patch extends the NIO integration test harness to track
file descriptors, in particular to search for leaks. This
change has been validated on Linux and Darwin, and in both cases
correctly diagnoses FD leaks.

The goal is to enable us to regression test for things like

Modifications

- Add support for hooking socket and close calls.
- Wire up this support into the test harness.
- Extend the test harness to handle the logging.
- Add new regression test for #2047.

Results

We can write regression tests for FD leaks.

* Disable FD checking in most builds.

I'm doing this for speed reasons

* Always print the leaked fds number
2023-04-26 08:38:18 -07:00
David Nadoba 6720612111 Drop Swift 5.5 (#2406)
* Drop Swift 5.5

* Use `swift-atomics` 1.1.0 with `Sendable` adoption
2023-04-17 08:40:35 +01:00
Cory Benfield 61043a36f6 Work around the SwiftPM layout change. (#2389)
Motivation:

SwiftPM has changed its default layout for packages in
apple/swift-package-manager#6144. This breaks our CI, which assumes the
prior layout. We should work around this.

Modifications:

Enhance the code to tolerate both layouts.

Result:

Integration tests run on all platforms
2023-03-13 06:40:31 -07:00
Cory Benfield 1a0f46b8cd Lift alloc counter Package.swift to 5.1 and add platforms (#2352)
Motivation:

Our allocation counter tests still build for 5.0 by default. This isn't
great, but we've been getting away with it because building for 5.7
requires changing the way we express our dependencies. Doing that is a
big breaking pain in the neck that requires changes in multiple repos.

As a shorter-term goal, however, to enable testing in at least one more
repo (swift-nio-ssh), this PR lifts the version to 5.1, which is the
last release compatible with the Package.swift dependency structure we
use but that supports the Platforms we need to express.

Modifications:

- Move allocation counter to 5.1
- Add platforms from swift-nio-ssh

Result:

We can write allocation counter tests for swift-nio-ssh.
2023-01-19 09:37:11 -08:00
David Nadoba 1ce136b4c3 Fix main nightly CI (#2337)
* Fix nightly CI

* conditionalization of signal for architecture
2023-01-09 18:34:48 +00:00
Cory Benfield 0760383b38 Measure allocations applying WS mask (#2333)
Motivation:

We're missing some alloc tests on the WS mask.

Modifications:

- Add extra alloc tests for the WS mask

Result:

We'll have more tests
2022-12-13 18:05:27 +00:00
David Nadoba 0b4edd8329 Add NIOBSDSocket.ProtocolSubtype (#2317)
* RawSocket prototype

* Conform `ProtocolSubtype` to `Hashable`

* Add public `NIOIPProtocol` type

Make `ProtocolSubtype` internal

* Subset of IANA protocols with an RFC

* Add `CustomStringConvertible` to `NIOIPProtocol`

* Add `init(_ rawValue: Int)`

* Rename `NIOBSDSocket.ProtocolSubtype.ip` to `.default`

* Add `NIOBSDSocket.ProtocolSubtype.mptcp`

and remove `NIOBSDSocket.mptcpProtocolSubtype`
2022-11-22 06:01:52 -08:00
Franz BuschandCory Benfield 1abe64c5e6 Add benchmarks for NIOAsyncWriter and NIOAsyncSequenceProducer (#2301)
# Motivation
We landed the async bridge types a while back but never added allocation and performance tests. Since we expect these types to be used performance critical paths we really should cover those with tests.

# Modification
Extends the allocation counter scaffolding to support async tests. Furthermore, add allocations tests for both the writer and producer. Lastly, I a also added a performance test for the producer.

# Result
We now have baseline tests for the `NIOAsyncWriter` and `NIOAsyncSequenceProducer`

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-10-26 03:51:20 -07:00