Commit Graph

16 Commits

Author SHA1 Message Date
Cory Benfield a7c36a7654
Clean up and regression check the docs. (#2400)
Motivation:

Up until recently, it has not been possible to regression check our
documentation. However, in recent releases of the DocC plugin it has
become possible to make warnings into errors, making it possible for us
to CI our docs.

This patch adds support for doing that, and also cleans up our
documentation so that it successfully passes the check.

Along the way I accidentally wrote an `index.md` for `NIOCore` so I
figure we may as well keep it.

Modifications:

- Structure the documentation for NIOCore
- Fix up DocC issues
- Add `check-docs.sh` script to check the docs cleanly build
- Wire things up to our docker-compose scripts.

Result:

We can CI our docs.

Co-authored-by: George Barnett <gbarnett@apple.com>
2023-04-11 09:05:22 +01:00
George Barnett 4dfae01cc6
Add a pooled recv buffer allocator (#2362)
Motivation:

Channels can read `ChannelOptions.maxMessagesPerRead` times from a
socket in each read cycle. They typically re-use the same buffer for
each read and rely on it CoWing if necessary. If we read more than once
in a cycle then we may CoW the buffer. Instead of reusing one buffer we
can reuse a pool of buffers limited by `maxMessagesPerRead` and cycle
through each, reducing the chance of CoWing the buffers.

Modifications:

- Extend `RecvByteBufferAllocator` to provide the size of the next
  buffer with a default implementation returning `nil`.
- Add an recv buffer pool which lazily grows up to a fixed size and
  attempts to reuse buffers where possible if doing so avoids CoWing.

Results:

Fewer allocations
2023-02-20 17:00:19 +00:00
David Nadoba 3d18e94683
Add Swift 5.8 CI and update nightly CI to Ubuntu 22.04 (#2350)
* Add Swift 5.8 CI

* Update nightly CI to Ubuntu 22.04

* Allow slight allocation variance in `1000_udpconnections` test
2023-01-18 10:17:12 +00:00
Philip Brown 59e1f6f375
Tail allocate mutex and a generic value using ManagedBuffer (#2349)
Motivation:

Currently, NIOLock and NIOLockedValueBox incur unnecessary allocation and indirection costs.

Modifications:

Create namespace LockOperations for organization
Create LockStorage<Value>, a subclass of ManagedBuffer<LockPrimitive, Value>
Store the mutex as the header and the generic value as the first and only element
Update NIOLock and NIOLockedValueBox to use LockStorage

Result:

Optimal lock and value memory layout
Fewer allocations and less indirection
Code generation is excellent
2023-01-17 16:11:10 +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
Franz Busch 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
George Barnett 39e61f636f
Update allocation limits (#2272)
Motivation:

a16e2f54a2 allocates more in some cases
because of an additional channel handler.

Modifications:

- Update alloc limits

Result:

CI passes.
2022-09-29 10:10:16 +01:00
Cory Benfield 6918034260
Update HTTP parser to LLHTTP (#2263)
Motivation:

The node.js HTTP parser library that we use has been unmaintained for some time. We should move to the maintained replacement, which is llhttp. This patch will update our dependency and bring us over to the new library, as well as make any changes we need.

Modifications:

This patch comes in 4 parts, each contained in a separate commit in the PR.

The first commit drops the existing http_parser code and updates some of the repo state for using llhttp.
The second commit rewrites the update script to bring in llhttp instead of http_parser.
The third runs the actual script. You can skip reviewing this except to sanity check the outcome.
The fourth commit updates the NIO code and the tests to get everything working.

In general the substance of the product modifications was minimal. The logic around keeping track of where we are in the buffer and how upgrades work has changed a bit, so that required some fiddling. I also had to add an error reporting path for the delegates to be able to throw specific errors that llhttp no longer checks for. Finally, I removed two tests that were a little overzealous and that llhttp does not police.

Result:

Back on the supported path.
2022-09-13 14:09:57 +01:00
Cory Benfield f5448fbbc2
Provide NIOAsyncTestingChannel (#2238)
Motivation

Testing versions of NIO code that involve interfacing with Swift
Concurrency is currently a difficult business. In particular,
EmbeddedChannel is not available in Swift concurrency, making it
difficult to write tests where you fully control the I/O.

To that end, we should provide a variation of EmbeddedChannel that makes
testing these things possible.

Modifications

Provide an implementation of NIOAsyncTestingChannel.

Results

Users can write tests confidently with async/await.
2022-08-10 11:09:56 +01:00
tomer doron 712e207f26
initial adoption of DocC based documentaiton (#2235)
* initial adoption of DocC based documentaiton

motivation: use DocC for docs

change:
* add DocC catalog to NIO target, as the "landing page"
* remove jazzy doc generation script
* add Package.swift with tools-version 5.6 so that DocC can be used, and add a dependency on the DocC plugin
* udpate soundness script

* * add packge.swift files for older vrsions
* adjust waning-as-error and enable-test-discovery to the different permutations

* fixup

* remove jazzy

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-08-08 03:55:18 -07:00
David Nadoba 0e2818bf86
Remove `@preconcurrency` from internal `EventLoopFuture` methods (#2135)
* add @preconcurrency again as it otherwise results in one more allcation in 1000_udpconnections
2022-06-07 07:09:44 -07:00
tomer doron aa631d3c8c
ci update (#2066)
motivation: 5.6 is out

changes:
* use release version of 5.6
* add docker setup for 5.7 (using nightly for now)
2022-03-16 21:28:58 -07:00
Cory Benfield af161d59f5
Add limits for the new test (#2060) 2022-03-08 09:22:15 +00:00
Fabian Fett c74c3bbabf
[SelectableEventLoop] SR-15872; Save allocations when appending task (#2046)
* [SelectableEventLoop] SR-15872; Save allocations when appending task

* Add pr to workaround list

* Update alloc counters

* Update alloc script to include 5.6

* Update alloc counters

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-02-17 12:18:21 -08:00
Fabian Fett c562f962b8
Add an allocation test for execute which needs to hop threads. (#2047)
* Add an allocation test for execute which needs to hop threads.

* Add new alloc limits for CI
2022-02-17 09:21:40 +00:00
Cory Benfield 398378653f
Add 5.6 nightly CI (#2032)
The 5.6 nightly images are available, let's use them.
2022-01-18 09:35:51 +00:00