ccc icon indicating copy to clipboard operation
ccc copied to clipboard

Improve RPC performance by avoiding JSON serialization cost

Open Hanssen0 opened this issue 7 months ago • 2 comments

See CKB RPC, some RPC methods support verbosity = 0:

When verbosity is 0, it returns a 0x-prefixed hex string as the result. The string encodes the block serialized by molecule using schema table Block.

It should avoid extra JSON serialization and deserialization costs. Whether molecule deserialization will incur additional costs should be tested.

Hanssen0 avatar Jun 16 '25 10:06 Hanssen0

JSON is likely vastly more optimized. For example V8 just made JSON.stringify more than twice as fast as before. There is also this easy-to-listen video that covers the article.

Phroi

phroi avatar Aug 18 '25 13:08 phroi

JSON is likely vastly more optimized. For example V8 just made JSON.stringify more than twice as fast as before. There is also this easy-to-listen video that covers the article.

Thank you for your sharing! @quake previously proposed this, and his point of view is that this can save the overhead of CKB node JSON serialization.

Benchmarks (from CKB node to nodejs) are definitely needed to figure out if this actually helps.

Hanssen0 avatar Aug 18 '25 14:08 Hanssen0