Motivation:
Networking software like SwiftNIO that always has explicit flushes
usually does not benefit from having TCP_NODELAY switched off. The
benefits of having it turned on are usually quite substantial and yet we
forced our users for the longest time to enable it manually.
Quite a bit of engineering time has been lost finding performance
problems and it turns out switching TCP_NODELAY on solves them
magically.
Netty has made the switch to TCP_NODELAY on by default, SwiftNIO should
follow.
Modifications:
Enable TCP_NODELAY by default.
Result:
If the user forgot to enable TCP_NODELAY, their software should now be
faster.
* Reorder ‘channel active’ calls to the same order as `_ChannelInboundHandler` and their likely chronological order.
Motivation:
When first viewing the example classes, coming to the ‘read’ method first, leaves the subject unclear as to what the method is ‘reading’.
It is preferable to view something being sent first, and then to view the reading of the response.
It also matches the call order against the protocol making it a little easier for those unfamiliar with the protocol to see which methods have been implemented.
Modifications:
Moved channel active calls to be top of the class.
Despite the diff there are no actual code modifications.
UDP Client changed to indent using spaces to match rest of project. Incidental change.
Result:
The examples are slighter clearer to read, particularly for newcomers to swift-no as the calls are in a logical chronological order.
* Fix an error in the upgrader and its tests which checked the connection header incorrectly.
Motivation:
To correct the logic in the upgrader. Previously it checked if the upgraders required headers include the connection header. Now it checks that the connection header value was present as a separate header in the incoming request.
To prepare the class naming for the presence of a client upgrader.
Modifications:
Slight change in server upgrader handler logic with accompanying tests.
Renamed upgrader and test files to include the word ‘server’.
Ran the linux test script.
Result:
The server upgrader now checks for the presence of the connection header value as a header of its own.
* Rename WebSocketServer upgrader to make the naming clearer and make way for a client version.
Motivation:
To make the web socket upgrader naming clearer, particularly once we add a client version.
Modifications:
Rename WebSocketUpgrader too WebSocketServerUpgrader.
Result:
Improved clarity of naming on the web socket upgrader.
* Adds correct naming conventions to NIOWebSocketServerUpgrader. Sets back an incorrect fix (non-fix).
* Move deprecation for NIOWebSocketServerUpgrader typealias out of API shims file.
* Makes HTTPEncoder removable.
Adds a client upgrade handler with tests.
Adds the ability to use a client upgrader to the client setup.
Initial linux file update.
* Allow assertContains to be accessed publicly, so that it can be used in the client side tests.
* Update tests to remove server upgrader from client tests.
Change client tests to use Embedded channel.
Update HTTPUpgradeConfiguration class name to be NIOHTTPServerUpgradeConfiguration
Few other small stylistic changes.
* Removed awaiting upgrader state.
Removed future from handle upgrade call as is synchronous.
Removed protocol iterator from handle upgrade call as is not required by the client.
* Ensure that the client handler calls for the HTTPPipeline are backwards compatible.
Ensure that incoming promises to the handler write call are completed.
Neaten the upgrade header formation to remove looping.
Improve the correctness of the upgrade error throwing.
* Update scripts to match new unit tests.
* Change the documentation for HTTPServerPipeline to remove nil options which have now been removed.
* Restore an incorrectly added server pipeline comment change and make it to the client pipeline instead.
* Raise the allocation limits in the docker images to allow the tests to pass.
Motivation:
For the allocation counter tests to be as useful as possible, we should
disallow limits that are too high, we should capture the allocation
count very close to where it actually is.
Modifications:
Don't allow any allocation counter test to allocate fewer than
'limit - 1000' allocations.
Result:
Better limits.
Motivation:
When using CircularBuffer as a storage object it would be helpful to be
able to write directly into the underlying storage. As the _modify
accessor is currently underscored and not really safe for us to use, the
next best option is to write a function that takes advantage of the
_modify access on the underlying Array. This patch provides that
function.
Modifications:
- Implemented CircularBuffer.modify(_:_:)
Result:
It'll be possible to use a fast function to access the underlying Array
storage.
motivation: prepare to run performance tests in ci
changes:
* add performance-test docker-compose task
* add script that can parse the performance test suite results and compare between two result-sets
* add generic shell docker-compose task
Motivation:
We still had a bunch of docker files for NIO on Swift versions that NIO2
doesn't actually work on. Also we had allocation counter limits in
places where they don't mean anything.
Modifications:
Prune all the useless information.
Result:
Less configuration.
Motivation:
Due to https://bugs.swift.org/browse/SR-10614, assigning an array containing a tuple type
to a variable that expects an array containing a different-but-compatible tuple type will cause
an allocation and copy of that array storage.
In some cases this is necessary, but we were doing it in the HTTPHeaders constructors, which meant
that the swift-nio-http2 code was hitting a hilariously over the top number of allocations.
Modifications:
- Change the internal storage type of HTTPHeaders to match the public constructor.
Result:
Fewer allocations when constructing HTTPHeaders
Motivation:
Swift 5.1 shows much fewer allocations, let's tighten the limits.
Modifications:
Tighten the allocation limits on 5.1.
Result:
We'll catch allocation regressions much more easily.
Motivation:
We should test all available Swift versions, including snapshots.
Modifications:
Add docker compose file for Swift 5.1.
Result:
More testing.
Motivation:
Our original Heap implementation used a bunch of static functions
in order to make it clear how it related to textbook heap
implementations. This was primarily done to ensure that it was easier
to see the correctness of the code.
However, we've long been satisfied with the correctness of the code,
and the Heap is one of the best tested parts of NIO. For this reason,
we should be free to refactor it.
Given https://bugs.swift.org/browse/SR-10346, we've been given an
incentive to do that refactor right now. This is because the Heap
is causing repeated CoW operations each time we enqueue new work
onto the event loop. That's a substantial performance cost: well
worth fixing with a small rewrite.
Modifications:
- Removed all static funcs from Heap
- Rewrote some into instance funcs
- Merged the implementation of insert into append.
- Added an allocation test to avoid regressing this change.
Result:
Faster Heap, happier users, sadder textbook authors.
Motivation:
We shouldn't put warnings in developer's code in the convergence phase.
Modifications:
- remove NIO1APIShims warning
- update Swift
Result:
fewer warnings
Motivation:
The HTTP/1 headers were quite complicated, CoW-boxed and exposed their
guts (being a ByteBuffer). In Swift 5 this is no longer necessary
because of native UTF-8 Strings.
Modifications:
- make headers simply `[(String, String)]`
- remove `HTTPHeaderIndex`, `HTTPListHeaderIterator`, etc
Result:
- simpler and more performant code
Motivation:
The old HTTP parser tried to convert `http_parser` to a one-shot parser
by pausing it constantly. That was done to be resilient against
re-entrancy. But now, we have the new `ByteToMessageDecoder` which
protects against that so HTTP decoder can just become a real
`ByteToMessageDecoder`. It also serves as a great testbed for
`ByteToMessageDecoder`.
Modifications:
- make the HTTP decoder a `ByteToMessageDecoder`
- refactor the implementation
Result:
cleaner code, more use of `ByteToMessageDecoder`
Motivation:
The allocation tests were needlessly running the resolver within the
allocation counted loop.
Modifications:
- bump to Swift version 5.0
- take the resolving out of the allocation counting loop
Result:
more accurate results
Motivation:
If ChannelHandler removal worked correctly, it was often either by
accident or by intricate knowledge about the implementation of the
ChannelHandler that is to be removed. Especially when it comes to
re-entrancy it mostly didn't work correctly.
Modifications:
- introduce a `RemovableChannelHandler` API
- raise allocation limit per HTTP connection by 1
(https://bugs.swift.org/browse/SR-9905)
Result:
Make things work by contruction rather than accident
Motivation:
Newer Swift versions are good and we should test them, this one threw a few curveballs at us:
- started using `posix_memalign` which needed fixing in our alloc tests (fixed in #782)
- the optimiser decided not to inline a function that needs to be inlined
Modifications
- `@inline(__always)` to help the optimiser
- update Swift version
Result:
- fixes#727
- fixes#726
Motivation:
Certain warnings we want to ignore in CI builds but we want to keep
`-warnings-to-errors` on.
Modifications:
define `NIO_CI_BUILD` in the CI builds
Result:
can ignore select warnings in CI
Motivation:
Forgot to introduce the -warnings-as-errors parameter in the `test:`
directive in the docker compose file.
Modifications:
added warnings-to-errors to the docker-compose.yml for 5.0
Result:
warnings to errors
Motivation:
Swift 5 contains a regression where we get 1 extra allocations for the
ByteBuffer read/write allocation test.
I will track this problem down but for now it's important to unblock
other NIO2 work.
Modifications:
raise the allowed allocations for the ByteBuffer RW test by 1
Result:
allocation tests can be re-enabled again.
Motivation:
Swift 5 contains a regression where we get 2 extra allocations per
HTTP/1.1 request/response pair _only on Linux_. That happens both on
`master` as well as on `nio-1.12`.
I will track this problem down but for now it's important to unblock
12 work.
Modifications:
raise the allowed allocations per HTTP/1.1 req/res pair to 38 (from 36)
for Swift 5.
Result:
allocation tests can be re-enabled again.
Motivation:
that snapshot fixes https://bugs.swift.org/browse/SR-9518 which blocks
the allocation tests and therefore #710 .
Modifications:
made our docker use the 2012-12-28 snapshot.
Result:
allocation tests hopefully work again because Swift doesn't accidentally
forget to decrease some reference count anymore.
Motivation:
SwiftPM was very outdated on the old Swift snapshots, we should update
the CI.
Modifications:
use swift-5.0-DEVELOPMENT-SNAPSHOT-2018-12-13-a-ubuntu18.04.tar.gz
Result:
can use swift-tools-version: 5.0 and all the goodies from that
Motivation: enable tests against swift 5.0
Modifications:
* add a docker-compose file for ubuntu 18.04 and swift 5.0-DEVELOPMENT-SNAPSHOT-2018-12-04-a
* update Dockerfile to correctly handle development builds
Result:
* you can now test against swift 5.0 with docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.1804.50.yaml run test
Motivation:
We always care most about the latest released Swift version. Therefore I
added allocation limits for Swift 4.2 and indicated that the old ones
can be removed as soon as they change.
Modifications:
- added allocation limits for Swift 4.2
- added a comment to the old ones that they don't need to be changed
anymore now
Result:
- best support for best version
- document that Swift 4.2 is awesome, lots fewer allocations!
Motivation:
Now that 4.2 has been released, there's no reason to use the CONVERGENCE
version anymore.
Modifications:
use the RELEASE instead of the CONVERGENCE version of Swift 4.2
Result:
use the latest and greatest
Motivation:
We should support the latest and greatest.
Modifications:
- add Ubuntu 18.04 support (packages exist for Swift 4.2 only)
- add Swift 4.2 support (for Ubuntu 14.04, 16.04 and 18.04)
Result:
- supporting the latest stuff
Motivation:
swift-nio example projects (http, echo) don't print anything to the console when running inside docker container because of buffering issue.
Modifications:
Added tty: true to the docker-compose.yaml for http & echo.
Result:
Buffering issue is resolved. http & echo prints logs to the console.
Motivation:
We knew since before that on Ubuntu 16.04 we have one more allocation
per connection that on 14.04 (presumably due to resolver differences or
something in the system). When I last updated the allocation limits
however I forgot that...
Modifications:
- raise 16.04 allocation limit by 1 allocation
Result:
- integration tests should pass on 16.04
Motivation:
Previously we were not running the (child/server)channelInitializers on the
event loop associated to the `Channel` we're initialising. Almost all
operations in there are pipeline modifications which are thread safe so
it presumably wasn't a massive correctness issue. However it's very
expensive to hop threads that often and it is also very unexpected. This
addresses this issue.
Modifications:
made all (child/server)channelInitializers run on the event loop that is
associated to their `Channel`
Result:
- more correctness
- less unexpected behaviour
Motivation:
If registration of a Channel fails we need to close that Channel.
Previously we'd just drop it on the floor which triggers an assertion
that an open channel got leaked.
Modifications:
In cases where the Channel registration fails, we need to close that
channel.
Result:
- No crashes if registration fails.
- fixes#417
Motivation:
We reduced allocations again, let's reset the limits.
Modifications:
lowed a bunch of limits to
- MAX_ALLOCS_ALLOWED_1000_reqs_1_conn=47000
- MAX_ALLOCS_ALLOWED_1_reqs_1000_conn=776100
- MAX_ALLOCS_ALLOWED_ping_pong_1000_reqs_1_conn=4600
- MAX_ALLOCS_ALLOWED_bytebuffer_lots_of_rw=3100
- MAX_ALLOCS_ALLOWED_future_lots_of_callbacks=99100
Result:
tighter limits should find regressions more easily
Motivation:
We don't want to regress the number of heap allocations we perform.
Modifications:
Added appropriate environment variables to Docker files.
Result:
Things go bang if we regress Future allocation counts.
Motivation:
be able to run the sanity check via docker compose
Modifications:
add sanity task to docker compose file
Result:
you can now run sanity check via docker
Motivation: easier testing across different permutations of os and language versions
Modifications:
* update dockerfile to take both swift_version adn ubuntu_version
* update default linux version to 16.04
* create multiple docker-compose files that use arguments to define os and swift versions
* make docker-compose file DRYer with yaml anchors
Result: users/ci can easily run tests across various versions of ubuntu and swift
Motivation:
In order to target the latest version of Swift and address this issue https://github.com/apple/swift-nio/issues/83
Modifications:
Set the Swift version to the latest (4.0.3)
Result:
Uniform version of Swift across the Ubuntu Docker image and a passing
test suite on all target platforms
Motivation:
When building our docker image a lot of warnings showed up.
Modification:
- Ensure we not try to start services on installation
- Redirect STDERR
- Remove some commented lines
Result:
Less warnings during building the docker image.
Motivation:
repository currently contains two seperate docker definitions that are confusing to users
Modifications:
* remove Dockerfile.xenial so we have a canonical docker file for CI and developer testing
* point docker compose to canonical docker file
* define docker compose services for unit and integration tests. and make "test" service run both
* update readme
Result:
users are less confused about docker setup
Motivation:
set up continuous integration
Modifications:
* update docker file to include all dependencies required for build, unit tests, integration tests and doc generation
* remove dependency steps from doc generation script
* add integration tests driver script
Result:
able to set up docker based continuous integration
Motivation:
We need to mount the ~/.ssh directory into the docker image as we use git@ to checkout our dependencies.
Modifications:
Use ~/.ssh as volume as well.
Result:
Be able to use docker images again.