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
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)`
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)`
* 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
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.
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.
- Also remove all methods that use Dispatch for now as we not need these
- Ensure we will detect if the user calls a blocking method while on the EventLoop and crash to guard against deadlock
This fixes a number of bounds checking issues, including changing the behavior of out of bounds access. Now if get is passed a negative value or a value beyond the size of the buffer, it explodes. If set is passed a negative value it also explodes, but values passed the end of the buffer continue to implicitly resize.