Commit Graph
1838 Commits
Author SHA1 Message Date
Johannes Weiß d9daac64cc make registration type-safe 2017-06-27 15:58:22 +01:00
Norman Maurer f35fb80c7e Make the promise optional for outbound operations.
This change allows the user to use `nil` as promise for outbound operations. This is useful if the user is not really interested in the outcome of the operations as it save extra allocations and so make things faster.

Before:
`Aggregate bandwidth: 10464.620↓, 10465.091↑ Mbps`

After (with using nil as Promise):

`Aggregate bandwidth: 11283.322↓, 11284.157↑ Mbps`
2017-06-27 14:37:24 +02:00
Johannes Weiß e9de0aca44 retry correctly on EINTR 2017-06-27 16:32:39 +01:00
Norman Maurer cb7850de08 Remove type argument for creating promise / future via EventLoop 2017-06-27 11:09:46 +02:00
Norman Maurer 6ff93721d3 Correctly call fireErrorCaught when in the EventhLoop and bootstrap a server 2017-06-27 08:32:51 +02:00
Norman Maurer d111028ede Make use of Future.whenComplete(...) when we are interested in the failure and success case 2017-06-27 08:31:16 +02:00
Norman Maurer 05a1f1e602 Slim down the Future / Promise
The user should use callbacks to access the value / error of the promise or wait() and not try to get it directly. This also did not work correctly because it was not correctly implemented in terms of thread-safety
2017-06-26 20:42:37 +02:00
Norman Maurer 07a5f8112e Fix test that was racy before and so failed on the CI 2017-06-26 21:09:05 +02:00
Norman Maurer 01e4eb512a Not try to re-register if already unregistered 2017-06-26 20:53:36 +02:00
Norman Maurer 661f8f0c39 Regenerate for linux to run the new test 2017-06-26 19:55:50 +02:00
Norman Maurer 23fef69586 Make Promise a struct for performance reasons.
Make the Promise a struct to improve performance. As the Promise only contains a reference it also not change any semantics for the user.

Before:

`Bandwidth per channel: 14367.103⇅ Mbps (1795887.9 kBps)`

After:

`Bandwidth per channel: 14772.899⇅ Mbps (1846612.4 kBps)`
2017-06-26 09:44:01 +02:00
Norman Maurer bea94aa2aa Not allow to add a ChannelHandler to the ChannelPipeline after the Channel was closed.
We should not allow to add a ChannelHandler to the ChannelPipeline after the Channel was closed, and so all handlers of the pipeline removed.
2017-06-26 08:57:45 +02:00
Norman Maurer 02e54db9a3 Remove two methods from ChannelCore which are not needed 2017-06-22 20:39:21 +02:00
Tom Doron 788b684151 test generation should not include timestamp
motivation: keep changeset smaller

changes: remove timestamp from test generator template, regenerate tests with new template
2017-06-22 11:36:31 -07:00
Norman Maurer 069543c456 Add test case for outbound handler ordering 2017-06-22 20:27:48 +02:00
Johannes Weiß 9db082a615 fix channel pipeline order (outbound was swapped) 2017-06-22 18:49:11 +01:00
Norman Maurer f92c0a09b8 Make naming in ChannelCore more consistent and remove implementation detail from protocol 2017-06-22 17:25:11 +02:00
Norman Maurer 4c6d8f748e Remove code that is already provided by Channel extension 2017-06-22 17:06:46 +02:00
Norman Maurer ea78014e00 Add assert to check that used Promise was not completed yet 2017-06-22 14:50:55 +02:00
Johannes Weiß 1bdeee7594 regenerate Linux tests 2017-06-22 12:36:37 +01:00
Johannes Weiß 1fe62e4afb fix Selectors being used after close 2017-06-22 10:43:42 +01:00
Johannes Weiß c1f2718786 fix undefined behaviour when loading integers (possibly misaligned) 2017-06-22 11:45:52 +01:00
Norman Maurer 1c5e0b4f9d Fix error in ByteBuffer test 2017-06-21 20:35:24 +02:00
Tom Doron a6bae8b759 linux support
motivation: be able to build and test on linux

changes:
* add dockerfile to create docker image running all toold required for testing on linux
* add readme with instruction on how to use the docker setup
* add script to generate linux tests mapping
* add .swift_version file to explicitly call out the swift version needed to build the project
* adjust code that did not build on linux, mainly casting between Int32 and Int
2017-06-21 10:58:28 -07:00
Johannes Weiß 8acf942565 fix memory leak when vector write call throws error 2017-06-21 15:37:42 +01:00
Norman Maurer dbb98eb905 Split ChannelHandler to ChannelInboundHandler and ChannelOutboundHandler
The mention change was done for performance reasons as often the user only either implement inbound or outbound operations per handler. The problem before was that we had to traverse the full list all the time even if the user was not really interested in either inbound or outbound events.

With this change we also split the doubly-linked-list into two linked-lists, one for inbound handlers and one for outbound handlers. This way we only need to traverse the handlers that are really interested in th event itself.

To give an idea about the impact of the change in terms of performance, here are some numbers.

Two ChannelInboundHandlers in the ChannelPipeline that do nothing and so just forward the events to the next handler in the pipeline:

Before:

`Bandwidth per channel: 18369.796⇅ Mbps (2296224.5 kBps)`

After:

`Bandwidth per channel: 20043.638⇅ Mbps (2505454.7 kBps)`
2017-06-21 14:35:33 +02:00
Norman Maurer f1f1829296 Call pipeline.removeHandlers() in a delayed fashion to ensure we are non executing pipeline code anymore 2017-06-21 08:34:22 +02:00
Norman Maurer ca794b158c Ensure we correctly handle deregister while still in the whenReady(...) method and using kqueue 2017-06-21 08:32:41 +02:00
Norman Maurer f091d61576 Remove the overhead of the tail and head context in the ChannelPipeline by skip their ChannelHandler if no custom action must be taken.
Also move the readIfNeeded() logic to Channel as it really belongs there.

Before:

 `Bandwidth per channel: 19004.576⇅ Mbps (2375571.9 kBps)`

After:
 `Bandwidth per channel: 21851.957⇅ Mbps (2731494.6 kBps)`
2017-06-20 14:28:04 +02:00
Norman Maurer 611048f2cc Not use errno wrapper 2017-06-19 20:48:45 +02:00
Norman Maurer 57cd379950 More consistent handling of writable state changes, so it matches netty 2017-06-19 15:05:29 +02:00
Norman Maurer 255afbdeca Fix multiple bugs while handling writes:
- Correctly update the readerIndex when a partal write for writev happens
- Correctly keep on writing if there are more flushed writes
2017-06-19 11:11:49 +02:00
Norman Maurer 179ec9f9dd Use the correct typealias when set and get SocketOption 2017-06-17 08:04:40 +02:00
Norman Maurer d788dc6794 Ensure SocketOption uses the correct types on linux and macos by using typealias for each platform 2017-06-16 21:08:47 +02:00
Norman Maurer 28c61c43e4 Remove ByteBuffer.skipBytes(...) as its reduntant with moveWriterIndex(forwardBy(...) 2017-06-16 20:26:53 +02:00
Johannes Weiß ecbda69fa9 fix pipeline stall (when no reads were happening and write returned EWOULDBLOCK) 2017-06-16 17:46:50 +01:00
Norman Maurer 88c7d34aa1 Fix compile error in EmbeddedChannelTest 2017-06-16 13:18:13 +01:00
Norman Maurer dea2a44c49 Add missing @discardResult 2017-06-16 13:16:03 +01:00
Norman Maurer 2ca36ad86a Remove duplicated code and also remove @discardResult where it makes no sense 2017-06-16 13:14:23 +01:00
Johannes Weiss c34eb26196 make IOData methods public 2017-06-16 11:46:12 +01:00
Kevin Clark 32fbec0b25 Fix Package.swift
* Export swift-nio library to package

* Add Package.resolved now that we're on swift 4
2017-06-16 03:06:52 -07:00
Kevin Clark 474ddadf00 Perf optimizations
* Remove unneeded hashValue from Future

And use Lock instead of NSLock. Seeing modest perf improvements.

* Annotate Promise and Future with final

* Use pthread_self equality rather than Thread

Seeing a 5x speedup in microbenchmarks
2017-06-16 02:11:27 -07:00
Johannes Weiß b73bfdab70 remove some existentials by specialising the data type (IOData) 2017-06-15 19:43:49 +01:00
Norman Maurer 4a6ed01491 Implement Future.wait() so we not pay an extra price if not used and so optimize the fast-path 2017-06-15 19:00:51 +01:00
Norman Maurer a7811b7b2d Add ByteBuffer.write(buffer) and set(buffer) 2017-06-14 19:19:29 +02:00
Norman Maurer b2491dae93 Add Package.resolved to gitignore 2017-06-14 15:57:13 +02:00
Johannes Weiß ba791a0ed5 new byte buffer 2017-06-12 17:42:07 +01:00
Norman Maurer 980085078c Use generic to remove the need of a forced cast. 2017-06-14 13:11:42 +02:00
Norman Maurer 6182f66a35 Remove use of DispatchQueue which was used to workaround https://bugs.swift.org/browse/SR-5145.
The use of DispatchQueue introduced a lot of overhead because it dispatched th ework to many threads. This could lead to have only one thread doing the IO while many others the actual deinit.

As we already limit the number of PendingWrite instances that will be written via writev to writevLimit we only need to take special action on failAll(...) which may possibly release thousands of PendingWrite instances and so could trigger a stackoverflow.
2017-06-13 15:18:51 +02:00
Norman Maurer 4f6723a0b3 Ensure we always mark the flush checkpoint, even if we are waiting for writable() to be called.
Previously we did not correctly mark the flush checkpoint if a call to writable() by the EventLoop was pending. This could have the affect that when the user calls flush while we already registered for InterestedEvent.write or InterestedEvent.all not all messages in the PendingWrite datastructure were correctly marked as flushed and so not written at the end when the writable call happens.
2017-06-13 12:34:53 +02:00