-
Notifications
You must be signed in to change notification settings - Fork 19
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
Speed up serialization and deserialization #55
Conversation
c316318
to
67b8fcf
Compare
770f31d
to
754c8b7
Compare
I don't really know how the changes can be reviewed, as they are massive! I think the tests are pretty complete and tests a lot of things, as well as the benchmarks which also verifies results. |
…ther than the result monad. * User facing API remains unchanged * This change speeds up deserialization by a factor of ~2
…o avoid int<->int64 conversions
… serialization and is now within a factor of x2 of ocaml-protoc in terms of serialization and deserialization speed
…stinction between proto2 and proto3 in the spec
…s. Also loop unroll varint encoding and add tests to verify correct encoding for varints.
…iting legth delimited fields, as well as loop unroll some functions.
… use seq under the assumption that List.of_seq is well optimized.
e0fefbe
to
17a6f0f
Compare
@AndreasDahl Any suggestions on how we can get this PR merged? I understand that its huge, but I believe the test coverage quite high. |
… flamba * Assume orderd fields when reading on fast-path and revert to a slow path if/when encountering unordered fields. * Sort fields to follow standard implementations * Change constructor to take extensions last to speedup handling of extensions * Delete locate options.ml as we require ocaml >=4.08
…e more fair to protoc
…eassurable faster than the simpler ones
With the latest optimizations, ocaml-protoc-plugin is now comparable with protoc: Numbers below shows relation to
Benchmark still shows x2 slower decoding on simple messages (messages with only one field). |
…and simplify read and write of varints. Using flambda, this has proven to be the fastest implementation.
@AndreasDahl Repinging on this again. I'll stop adding commits to this for now, and I'll look into some of the other issues. However, I'd like to get this merged soon, as I intend to base future work on top of this. Could I ask for a quick review? I don't know if you have some tests that you can run on top of this code (if its still being used actively), but I don't think an in-depth review is sensible at this point with all the changes made. |
@hongy20 (as representing the @issue/platypus team who are marked as CODEOWNERS) , @AndreasDahl do you have suggestions on how to proceed on this? I propose that we either.
In case I don't get a timely response, I will start merging to main and prepare a new release, but its really not an ideal solution. I would much rather prefer 3. if Issuu has no interest in maintaining these repositories. I would propose the same for ocaml-zmq repository which also have a stale PR. ocaml-zmq repository should be transferred to the ocaml community though. |
Note that I really do not prefer solution 2 and think we should avoid if possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the late review. I'll start the discussion internally on how we want to maintain this going forward.
Benchmarking against ocaml-protoc showed a huge number of allocations for both serialization and deserialization, which prompted some work on speeding up serialization and deserialization:
Other changes includes:
For simple structures, ocaml-protoc-plugin is still slower than
ocaml-protoc
, but for more complex structures speed is comparable.I'll note that
ocaml-protoc
has chosen to be non-compliant, and uses c stubs for faster encoding and decoding. Some observations onocaml-protoc
: