Replace Netty based RFC 1123 date encoding (#3527)
fixes #3527 /claim #3527
Deploy Preview for zio-http ready!
| Name | Link |
|---|---|
| Latest commit | cac56dd45586c670fba852ff525b9fe44cb39796 |
| Latest deploy log | https://app.netlify.com/projects/zio-http/deploys/685c1b980c93cd000808ad5d |
| Deploy Preview | https://deploy-preview-3550--zio-http.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.
Here is an efficient implementation of parsing/formatting for different timestamp formats including RFC 1123. Most performance tricks were ported from jsoniter-scala routines for JSON parsing and serialization of different data time values.
Java's DateTimeFormatter is ~10x times slower and affects scalability by eating memory bandwidth greatly. Even when using caching for formatting it introduces much bigger tail latency during refreshing of formatted values.
@guizmaii Implemented some benchmarks
Before your suggested changes
Benchmark Mode Cnt Score Error Units
DateEncodingBenchmark.nettyDecoding thrpt 3 439288.041 ± 1092690.136 ops/s
DateEncodingBenchmark.nettyDecodingInvalid thrpt 3 427059.216 ± 895231.682 ops/s
DateEncodingBenchmark.nettyEncoding thrpt 3 635390.868 ± 1403521.676 ops/s
DateEncodingBenchmark.zioHttpDecoding thrpt 3 2317595.133 ± 2830576.722 ops/s
DateEncodingBenchmark.zioHttpDecodingInvalid thrpt 3 2443173.737 ± 219913.014 ops/s
DateEncodingBenchmark.zioHttpEncoding thrpt 3 1095266.738 ± 378289.638 ops/s
After
Benchmark Mode Cnt Score Error Units
DateEncodingBenchmark.nettyDecoding thrpt 3 471698.844 ± 401495.065 ops/s
DateEncodingBenchmark.nettyDecodingInvalid thrpt 3 433314.955 ± 208199.739 ops/s
DateEncodingBenchmark.nettyEncoding thrpt 3 596804.828 ± 1649578.829 ops/s
DateEncodingBenchmark.zioHttpDecoding thrpt 3 2327353.872 ± 2900047.041 ops/s
DateEncodingBenchmark.zioHttpDecodingInvalid thrpt 3 17922976.451 ± 3374509.274 ops/s
DateEncodingBenchmark.zioHttpEncoding thrpt 3 1054091.409 ± 1728102.469 ops/s
The invalid case has explicitly strings with invalid length.
Cool job! Although why not make these changes in Netty code for everyone to benefit?
@nau
Although why not make these changes in Netty code for everyone to benefit?
I can be wrong but I think the idea is probably to have this code in pure Scala so that it compiles to JS and Native and reduces the dependency on Netty
@nau @guizmaii There are two reasons.
- We want to be independent of Netty. Not only for JS/Native, but also to be able to offer different backends in the JVM.
- Nettys formatter supports not only RFC1123 dates. We can optimize here by failing for any other date then RFC1123 dates