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

Implement a very lazy translation of headers #117

Merged
merged 1 commit into from Jan 2, 2019

Conversation

Projects
None yet
2 participants
@pushkarnk
Copy link
Contributor

pushkarnk commented Dec 14, 2018

This pull request proposes a very lazy translation of HTTPHeaders to HeadersContainer. The difference between these structures, that matters most, is the conformance to Collection. HeadersContainer is a Collection, HTTPHeaders isn't.

Conforming HTTPHeaders to Collection via an extension isn't straightforward. A conformance to Collection using the existing API leads to a very inelegant and sub-optimal implementation.

In that case, the only alternative we are left with is an "as lazy as possible" translation. Inside HeadersContainer, we maintain an extra backing store of type HTTPHeaders. The existing backing store, a Dictionary lies dormant. Only when the user code tries to access the HeadersContainer as Collection, a translation is done and the Dictionary backing store comes to life. Subsequently, we update both the backing stores. This is to make sure there's no need for the HeadersContainer to HTTPHeaders translation.

In short, the HTTPHeaders -> HeadersContainer is done very lazily and the vice versa isn't needed.

@pushkarnk

This comment has been minimized.

Copy link
Contributor

pushkarnk commented Dec 14, 2018

On TechEmpower/JSON this yields a benefit of around 8-9%.

@pushkarnk

This comment has been minimized.

Copy link
Contributor

pushkarnk commented Dec 14, 2018

Also, I've realised that though the Kitura tests have enough test coverage for HeadersContainer, the Kitura-NIO repo is negligible coverage. I'm planning to write tests as a part of this pull request.

@pushkarnk

This comment has been minimized.

Copy link
Contributor

pushkarnk commented Dec 17, 2018

Looks like a change to BlueSSLService is breaking Kitura-NIO on Darwin

IBM-Swift/BlueSSLService@468d581#diff-92ba0ed683849bc916d3ff460ce0b4b6

@pushkarnk pushkarnk force-pushed the pushkarnk:headers-opt branch from b506932 to c5e1312 Dec 17, 2018

@nethraravindran

This comment has been minimized.

Copy link
Contributor

nethraravindran commented Dec 17, 2018

BlueSSLService bug has been fixed in IBM-Swift/BlueSSLService#67 and tagged

@pushkarnk pushkarnk force-pushed the pushkarnk:headers-opt branch from a35bd56 to 3bb5347 Dec 19, 2018

@pushkarnk pushkarnk requested a review from nethraravindran Dec 19, 2018

@pushkarnk pushkarnk force-pushed the pushkarnk:headers-opt branch from 3bb5347 to e9ca626 Dec 19, 2018

@pushkarnk

This comment has been minimized.

Copy link
Contributor

pushkarnk commented Dec 26, 2018

A summary of the perf gains this PR gives on the different TechEmpower benchmarks (column lazy indicates the new numbers). All measurements are in MB/s.

Plaintext(Number of connections) 1.0.7 lazy KituraNet
256 12.02 14.5 14.83
1024 11.93 14.17 13.66
4096 11.56 14.16 12.21
16384 11.57 13.73 11.37
JSON (Number of connections) 1.0.7 lazy KituraNet
8 5.43 6.67 8.81
16 7.79 8.89 11.29
32 9.26 10.73 11.39
64 9.39 11.4 11.37
128 9.42 11.6 11.41
256 9.49 11.66 11.4
DB(Number of connections) 1.0.7 lazy KituraNet
8 2.96 3.18 3.59
16 4.39 4.79 5.21
32 4.82 5.24 6.04
64 4.87 5.41 6.61
128 4.9 5.56 6.81
256 5.07 5.64 6.82
 
Updates(Number of queries) 1.0.7 lazy KituraNet
-- -- -- --
1 2.96 3.1 5.16
5 1.71 1.71 1.8
10 1.39 1.4 1.43
15 1.27 1.27 1.29
25 1.16 1.16 1.18
Queries (Number of queries) 1.07 lazy KituraNet
1 3.94 4.18 5.12
5 2.63 2.71 3.02
10 2.41 2.45 2.58
15 2.29 2.31 2.4
20 2.24 2.23 2.3
25 2.2 2.17 2.25
Implement a very lazy translation of headers
Add HeaderContainer tests in dual mode

@pushkarnk pushkarnk force-pushed the pushkarnk:headers-opt branch from e9ca626 to f82886e Dec 26, 2018

@pushkarnk pushkarnk merged commit e64b14d into IBM-Swift:master Jan 2, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@pushkarnk

This comment has been minimized.

Copy link
Contributor

pushkarnk commented Jan 2, 2019

For the records, these are the %age gains on the different TechEmpower benchmarks:

Plaintext: 18-22%
JSON: 14-23%
DB: 7-13%
Updates: 0-4%
Queries: 0-6%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment