55 Commits
Author SHA1 Message Date
Johannes Weiss d9dc73592b 5.1-DEVELOPMENT-SNAPSHOT-2019-07-19-a (#1079) 2019-07-20 19:50:51 +01:00
tomer doron eeac3d51d9 add swift-api-digester docker setup (#1067)
motivation: prepare to run swift-api-digester in ci

changes:
* add jq to docker setup
* remove redundant ruby setting from docker file
2019-07-16 17:48:40 -07:00
Johannes Weiss c71df779ba 5.1 DEVELOPMENT-SNAPSHOT-2019-07-09-a (#1062) 2019-07-11 21:25:37 +01:00
Johannes Weiss 7f20464df3 enable TCP_NODELAY by default (#1020)
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.
2019-06-19 18:04:01 +01:00
Johannes Weiss 39e60dd694 5.1-DEVELOPMENT-SNAPSHOT-2019-06-17-a (#1043) 2019-06-19 08:43:05 +01:00
Liam Flynn 57785e6d9c An HTTP upgrader class for a client pipeline. (#1001)
* 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.
2019-06-16 11:10:12 +01:00
Johannes Weiss 8112653e28 alloc counters: disallow too high limits (#1022)
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.
2019-06-02 18:17:58 +01:00
Johannes Weiss 19aa7bf77d 5.1-DEVELOPMENT-SNAPSHOT-2019-05-29-a (#1021) 2019-05-30 14:08:30 +01:00
Cory Benfield 54935344c4 Provide CircularBuffer.modify(_:_:). (#1009)
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.
2019-05-26 09:14:57 +01:00
tomer doron c1aff57ba4 add performance analysis docker-compose setup and script (#1013)
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
2019-05-23 11:37:21 +01:00
tomer doron ed50f8a41e replace redundant commands in docker-compose files with generic one (#1010)
Motivation: keep it DRY

Modifications: move redundant commands from 18-04-5.0 and 16.04-5.1 to the generic task definitions
2019-05-21 09:12:05 -07:00
Johannes Weiss a836b78c7a prune docker compose files (#1007)
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.
2019-05-18 07:10:26 +01:00
Cory Benfield 768c3ab328 Avoid unnecessary allocation by way of tuple conversion. (#994)
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
2019-05-03 21:12:19 +01:00
Johannes Weiss 9e451149ca lower allocation limits for Swift 5.1 (#995)
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.
2019-05-03 19:10:25 +01:00
Johannes Weiss ba3733aa3a add Swift 5.1 docker file (#991)
Motivation:

We should test all available Swift versions, including snapshots.

Modifications:

Add docker compose file for Swift 5.1.

Result:

More testing.
2019-05-02 14:21:06 +01:00
Cory Benfield 0179535b99 Simplify Heap implementation. (#960)
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.
2019-04-10 13:53:07 +01:00
Johannes Weiss 874a883e33 use Swift 5.0-RELEASE (#926)
Motivation:

Now that Swift 5 is released, we should use the release version.

Modifications:

switch to Swift 5.0-RELEASE.

Result:

newer, shinier
2019-03-26 08:49:10 +00:00
Johannes Weiss 32b0be4626 DEVELOPMENT-SNAPSHOT-2019-03-10-a (#920) 2019-03-25 12:19:58 +02:00
Johannes Weiss 577604e850 disable NIO1APIShim's warning (#889)
Motivation:

We shouldn't put warnings in developer's code in the convergence phase.

Modifications:

- remove NIO1APIShims warning
- update Swift

Result:

fewer warnings
2019-03-08 18:10:03 +00:00
Johannes Weiss 22e6cd3c67 HTTP/1 headers simplification & cleanup (#857)
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
2019-03-06 18:11:40 +00:00
Johannes Weiss f1efb4a104 new http parser (#814)
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`
2019-03-06 11:51:42 +00:00
Johannes Weiss 65e5df240b DEVELOPMENT-SNAPSHOT-2019-03-04-a (#871) 2019-03-05 12:48:58 +00:00
Johannes Weiss ac26c7298d slight improvements to the allocation tests (#859)
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
2019-03-01 18:53:25 +00:00
Johannes Weiss fda5e5f334 update to 5.0-DEVELOPMENT-SNAPSHOT-2019-02-20-a (#832) 2019-02-21 16:27:00 +00:00
Johannes Weiss 30446eea52 update to 5.0-DEVELOPMENT-SNAPSHOT-2019-02-06-a (#821) 2019-02-13 10:14:41 +01:00
Johannes Weiss d938264fcb better ChannelHandler removal API (#767)
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
2019-02-12 11:27:48 +01:00
Johannes Weiss c45c7e181c use DEVELOPMENT-SNAPSHOT-2019-01-28-a
Motivation:

New Swift versions are great.

Modifications:

Upgrade to 5.0-DEVELOPMENT-SNAPSHOT-2019-01-28-a.

Result:

Should unblock #769.
2019-01-29 11:52:20 +00:00
Johannes Weiss 58a58b9680 CI: use DEVELOPMENT-SNAPSHOT-2019-01-23-a (#780)
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
2019-01-25 23:50:01 +00:00
Johannes Weiss 72370b6b42 defined NIO_CI_BUILD in the CI builds (#765)
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
2019-01-21 15:24:51 +00:00
Johannes Weiss a5b6ca06ab actually enable warnings as errors (#759)
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
2019-01-19 20:32:13 +00:00
Johannes Weiss 3ce1c25dfb raise Swift 5 ByteBuffer read/write allocation limit (#729)
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.
2019-01-03 08:25:04 +00:00
Johannes Weiss 0221ab8efc raise Swift 5 HTTP/1 req/res pair alloc limits (#725)
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.
2019-01-02 19:35:17 +00:00
Johannes Weiss e41c21c42c use the Swift 5.0 snapshot from 2018-12-28 (#724)
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.
2019-01-02 17:00:32 +00:00
Johannes Weiss 885ac373ad fix remaining warnings & -warnings-as-errors (#712)
Motivation:

Warnings are bad.

Modifications:

- fixed remaining warnings
- enabled -warnings-as-errors

Result:

happier devs
2018-12-17 17:13:25 +00:00
Johannes Weiss b154b1988a CI: update to Swift snapshot 13th Dec 2018 (#703)
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
2018-12-14 10:52:38 +00:00
tomer doron 94c2bc4d25 add support for swift 5.0 (#679)
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
2018-12-06 14:25:02 -08:00
Johannes Weiss 79267e893b make the allocation limits for Swift 4.2 the main ones (#621)
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!
2018-09-20 21:21:11 +01:00
Johannes Weiss cb2367f391 CI: use Swift 4.2-RELEASE instead of CONVERGENCE (#616)
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
2018-09-18 17:10:37 +01:00
Johannes Weiss 89603d6244 add Ubuntu 18.04 and Swift 4.2 support (#604)
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
2018-09-07 14:54:23 -07:00
Eugen a8a18ba222 add 'tty: true' to the docker-compose file (#490) (#491)
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.
2018-06-25 21:11:58 +01:00
Johannes Weiss 5b8b28a986 raise Ubuntu 16.04 allocation limit by 1 allocation (#441)
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
2018-05-24 21:03:13 +02:00
Johannes Weiß 80363d9d8c fix EventLoops that Bootstrap channel initialiser's call out on (#424)
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
2018-05-22 15:58:43 +01:00
Johannes Weiss ec880b0853 don't just drop Channels on the floor if registration fails
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
2018-05-22 11:29:20 +01:00
Johannes Weiß 325bbdd242 lower allocation limits (#390)
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
2018-05-04 18:45:11 +01:00
Cory Benfield 1013cddd8f Track Future allocations in CI. (#376)
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.
2018-05-01 15:10:36 +01:00
tomer doron 093328e1b3 expose sanity script through docker compose (#375)
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
2018-05-01 03:12:05 -07:00
tomer doron 8914a5536e extend docker setup to multiple version of ubuntu and swift (#357)
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
2018-05-01 08:56:39 +01:00
Tiago Martinho 8e98d84076 Set Swift version to 4.0.3 in Docker configuration (#89)
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
2018-03-12 18:47:46 +09:00
Norman Maurer c8d1980207 Cleanup DockerFile to eliminate warnings (#121)
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.
2018-03-11 22:53:08 +09:00
Stuart Hinson c583298096 Download curl from https endpoint (#116) 2018-03-09 02:03:00 +09:00