Improve JSON RPC performances
Context
This MR adds an ad hoc json_to_string
function to the RPC server in order to bypass Data_encoding
current conversion function that calls a costly pretty-printer. A cleaner fix would be to make this optimization in Data_encoding
itself but this requires a lot of side-work to make octez compatible with the Data_encoding
v1.0 which is currently not the case.
This speeds up the performances by a factor of 2 on average (for both floating and cemented blocks) as seen in the following benchmark data:
Performances logs
JSON RPC blocks per second (on floating blocks):
#### WITHOUT patch
2023/06/09 13:39:29.289208 INFO Processed 384 blocks in 10.14s (24 calls, height 3203457)
2023/06/09 13:39:39.511137 INFO Processed 464 blocks in 10.22s (29 calls, height 3203921)
2023/06/09 13:39:49.837954 INFO Processed 528 blocks in 10.32s (33 calls, height 3204449)
2023/06/09 13:40:00.199074 INFO Processed 304 blocks in 10.36s (19 calls, height 3204753)
2023/06/09 13:40:10.236986 INFO Processed 448 blocks in 10.03s (28 calls, height 3205201)
2023/06/09 13:40:20.679198 INFO Processed 368 blocks in 10.44s (23 calls, height 3205569)
2023/06/09 13:40:31.030091 INFO Processed 304 blocks in 10.35s (19 calls, height 3205873)
2023/06/09 13:40:41.308870 INFO Processed 336 blocks in 10.27s (21 calls, height 3206209)
2023/06/09 13:40:51.444492 INFO Processed 368 blocks in 10.13s (23 calls, height 3206577)
2023/06/09 13:41:01.532440 INFO Processed 416 blocks in 10.08s (26 calls, height 3206993)
---------------
#### WITH patch
2023/06/09 13:36:30.268240 INFO Processed 880 blocks in 10.07s (55 calls, height 3203953)
2023/06/09 13:36:40.393561 INFO Processed 864 blocks in 10.12s (54 calls, height 3204817)
2023/06/09 13:36:50.433017 INFO Processed 848 blocks in 10.03s (53 calls, height 3205665)
2023/06/09 13:37:00.557185 INFO Processed 688 blocks in 10.12s (43 calls, height 3206353)
2023/06/09 13:37:10.623808 INFO Processed 720 blocks in 10.06s (45 calls, height 3207073)
2023/06/09 13:37:20.805373 INFO Processed 768 blocks in 10.18s (48 calls, height 3207841)
2023/06/09 13:37:31.026773 INFO Processed 768 blocks in 10.22s (48 calls, height 3208609)
2023/06/09 13:37:41.131567 INFO Processed 800 blocks in 10.1s (50 calls, height 3209409)
This MR is a follow-up of !8976 (merged)
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rst
for the protocol and the environment,CHANGES.rst
at the root of the repository for everything else). -
Select suitable reviewers using the Reviewers
field below. -
Select as Assignee
the next person who should take action on that MR
Edited by vbot