-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance: Avoid converting responses to serde_json::Value
Previously, all responses were converted to serde_json::Value before being serialized to string. Since jsonrpc does not inspect the result object in any way, this step could be skipped. Now, result objects are serialized to string much earlier and the Value step is skipped. This patch has large performance benefits for huge responses: In tests with 4.5 GB responses, the jsonrpc serialization overhead after returning from an rpc function was reduced by around 35%. Which means several seconds of speed-up in response times. To accomplish this while mostly retaining API compatibility, the traits RpcMethod, RpcMethodSync, RpcMethodSimple are now generic in their return type and are wrapped when added to an io handler. There's now a distinction between the parsed representation of jsonrpc responses (Output/Response) and result of rpc functions calls (WrapOutput/WrapResponse) to allow the latter to carry the pre-serialized strings. Review notes: - I'm not happy with the WrapOutput / WrapResponse names, glad for suggestions. - Similarly, rpc_wrap must be renamed and moved. - The http handler health request is now awkward, and must extract the result/error from the already-serialized response. Probably worth it. - The largest API breakage I could see is in the middleware, where the futures now return WrapOutput/WrapResult instead of Output/Result. - One could make WrapOutput just be String, but having a separate type is likely easier to read. See #212
- Loading branch information
Showing
14 changed files
with
261 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.