New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eventloop + future optimizations #57

Merged
merged 3 commits into from Jan 27, 2018

Conversation

Projects
None yet
2 participants
@tanner0101
Copy link
Contributor

tanner0101 commented Jan 26, 2018

No description provided.

@tanner0101 tanner0101 added this to the 1.0 milestone Jan 26, 2018

@tanner0101 tanner0101 self-assigned this Jan 26, 2018

@tanner0101 tanner0101 referenced this pull request Jan 26, 2018

Merged

chttp refactor #211

@@ -103,7 +103,11 @@ public struct Future<T>: FutureType {
if let result = promise.result {
callback(result)
} else {
promise.awaiters.append(.init(callback: callback))
if promise.firstAwaiter == nil {

This comment has been minimized.

@Joannis

Joannis Jan 26, 2018

Contributor

Absolutely brilliant

@@ -1,6 +1,8 @@
import Dispatch
import Foundation

private let maxExcessSignalCount: Int = 2

This comment has been minimized.

@Joannis

Joannis Jan 26, 2018

Contributor

I found the performance goes up quite significantly if this is 3

@@ -1,6 +1,8 @@
import Dispatch
import Foundation

private let maxExcessSignalCount: Int = 2

This comment has been minimized.

@Joannis

Joannis Jan 26, 2018

Contributor

3 worked better for me in HTTP Engine

fatalError("SocketSource readSource illegally nil during signal.")
guard downstreamIsReady else {
// downstream is not ready for data yet
excessSignalCount += 1

This comment has been minimized.

@Joannis

Joannis Jan 26, 2018

Contributor

excessSignalCount = excessSignalCount &+ 1

I prefer using &+ in low level libraries (when safety is guaranteed). Since the check one line beneath basically guarantees no overflow will happen I think this worth it.

&+ and &- remove the over/underflow checks from the single operation, which saves about 2-4x the performance.

@@ -49,10 +49,12 @@ extension InputStream {
/// Data notification sent by the `OutputStream` in response to requests to `OutputRequest.requestOutput`.
///
/// - parameter input: the element signaled
@available(*, deprecated, message: "test")

This comment has been minimized.

@Joannis

Joannis Jan 26, 2018

Contributor

Are these on purpose?

@Joannis
Copy link
Contributor

Joannis left a comment

Do have a look at the maxExcessSignalCount

tanner0101 added some commits Jan 27, 2018

@tanner0101 tanner0101 merged commit 73369be into beta Jan 27, 2018

2 checks passed

ci/circleci: linux Your tests passed on CircleCI!
Details
ci/circleci: macos Your tests passed on CircleCI!
Details

@tanner0101 tanner0101 deleted the suspend-optim branch Jan 27, 2018

@tanner0101 tanner0101 added this to Done in Vapor 3 Feb 12, 2018

@tanner0101 tanner0101 removed this from Done in Vapor 3 Mar 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment