v0.3.1
v0.3.1
This version is mostly performance improvements & refactoring of current codebase.
Features
- Panko::JsonValue - wrapper for json values to use Panko::Response
Performance Improvements
- Caching types in attributes - Instead of re-fetching the type of attribute every time, we cache it and invalid it based on the record class being serializer.
- Moving attributes & associations to be backend behind C structs - and saving the name of attribute/association string and symbol to avoid necessary conversions
- Type Casting of JSON - is now done using Oj instead of relying on AR type to do the deserialization
- Caching serializer between runs - In method attributes, we create serializer instance, now between runs we cache it so we don't need to re-create.
We can't talk about performance improvements without showing some numbers!
Real-world benchmark:
I used the infrastructure in work and popular endpoint that serializes 7,884 entries,
here is are different between v0.2.2 and this version -
Metric | v0.2.2 | v0.3.1 |
---|---|---|
Avg Response Time | 2.10s | 1.46s |
Max Response Time | 2.40s | 1.90s |
99th Response Time | 2.35s | 1.67s |
Requests Per Second | 0.47 | 0.68 |
Total Requests | 142 | 205 |
the tests were done on different environment for testing only with wrk - 5 minute
Thanks to Bringg (my employer) for providing the infrastructure & data for those benchmarks.
Benchmarks:
Benchmark | v0.2.2 ip/s | v0.3.1 ip/s |
---|---|---|
Panko_SimpleWithMethodCall_Posts_2300 | 82.47 | 92.63 |
Panko_SimpleWithMethodCall_Posts_50 | 4,480.92 | 5,097.98 |
Panko_HasOne_Posts_2300 | 46.86 | 60.8 |
Panko_HasOne_Posts_50 | 3,040.04 | 3,774.9 |
Panko_Simple_Posts_2300 | 89.57 | 132.99 |
Panko_Simple_Posts_50 | 5,605.79 | 6,619.94 |
ran using rake sanity
on my MacBook Pro (Retina, 15-inch, Mid 2015)