Tags: BGDV-HQ/swift-nio
Tags
Remove use of removeAll(keepingCapacity:). (apple#1699) Motivation: As outlined in https://bugs.swift.org/browse/SR-13923, removeAll(keepingCapacity:) on Array has particularly negative performance when that Array is not uniquely referenced. In this case, in EmbeddedChannel, we _arrange_ to multiply reference it. This makes it swamp our HTTP/2 microbenchmarks, spending more cycles copying this buffer around than doing anything else. Modifications: - Just allocate a new buffer instead. Result: Much less copying.
Conform TimeAmount to AdditiveArithmetic (apple#1691) Conforms TimeAmount to AdditiveArithmetic. Motivation: TimeAmount does not support -=, +=. Sometimes it is useful to manipulate time amounts when building up a delay and if that iteration fails, we would want to delay += .milliseconds(5) to add 5 milliseconds to our delay and try again. Modifications: Conformed TimeAmount to AdditiveArithmetic: added a static zero property and required operators. Result: TimeAmount conforms to AdditiveArithmetic. Co-authored-by: Josh <[email protected]> Co-authored-by: Cory Benfield <[email protected]>
Minor cleanups of Windows compatability code. (apple#1663) Motivation: Cleanup some noise that came in with some previous Windows compat patches. Modifications: - Move INVALID_SOCKET to NIOBSDSocket, and refer to it by a better name there. - Comment in an empty block to indicate that it's supposed to be empty. Result: Bit cleaner code.
Note that certain NIOFileHandle.init overloads are blocking (apple#1630) This was noted in review of swift-server/async-http-client#275, but I don't think that this was clearly stated in the documentation.
Better handle writability changes in triggerWriteOperations (apple#1624) Motivation: If a write is buffered in the `PendingWritesManager` and the high watermark is breached then a writability change will be fired as a result. The corresponding event when the channel becomes writable again comes when enough pending bytes have been written to the socket (i.e. as a result of a `flush()`) and we fall below the low watermark. However, if a promise associated with a write has a callback registered on its future which writes enough data to breach the high watermark (and also flushes) then we will re-entrantly enter `flushNow()`. This is okay, `flushNow()` protects against re-entrancy and any re-entrantly enqueud flushed writes will be picked up in the write-spin-loop. The issue here is that the `writeSpinLoop` does not monitor for changes in writability. Instead if checks the writability before it begins and after it completes, only signalling if there was a change. This is problematic: the re-entrant write-and-flush could have caused the channel to become unwritable yet no event will be fired to make it writable again! Modifications: - Store a local writability state in the pending writes manager and modify it when we emit writability changes Result: - Better protection against re-entrant writability changes.
Linux: make `Epoll` available on Android (apple#1621) Android is sufficiently Linux-esque that it should be able to use `Epoll`.
Avoid including non-modular headers. (apple#1605) Motivation: We included netinet/ip.h in CNIODarwin, which unfortunately is not modularised. This causes issues when using SwiftPM to create xcodeproj files. There's no real reason to do it this way, when we can just as easily abstract the issue. Modifications: - Moved netinet/ip.h to the .c file instead of the .h. - Defined some exported namespaced integers to correspond to the macros. - Performed platform abstraction in Posix instead of everywhere. Result: - Creating xcodeproj files should be fine.
Don't use deadbeef for dead pointers. (apple#1604) Motivation: It turns out using this overflows Int on "Any iOS Device" Modifications: Switch the first d to a 7. Result: Code will compile on "Any iOS Device".
Don't install Jazzy on Xenial (apple#1597) Motivation: Ruby on Xenial is too old for the cocoapods downloader which jazzy uses. Modifications: Change Dockerfile to not install Jazzy on xenial. Result: Dockerfile will build again, but bionic or later is required for docs.
Make UDP connection allocation test more like best practice code. (ap… …ple#1583) Motivation: There is at least a theoretical race to flush before close in prior version. Having terrible code in the NIO repo is asking for someone to copy it. Modifications: flatMap the various parts of the client together which also ensures the flush is complete before close is called. Result: Slightly nicer code, slightly fewer allocations.
PreviousNext