CosmWasm / serde-json-wasm

serde_json for Wasm programs (small, deterministic, no floats)
Apache License 2.0
30 stars 15 forks source link

String parsing optimization #25

Closed maurolacy closed 3 years ago

maurolacy commented 3 years ago

Improves string serialization / deserialization. Attempts at closing #16.

Significant improvements in deserialization, following Ethan's suggestions in #16.

Slight improvements (~10%) in serialization. To try and improve on this, I can't think of anything else than trying with an external / optimized escaping crate / lib.

Any ideas?

maurolacy commented 3 years ago

How do you measure the performance changes? I always compiled it into a local contract and measured the gas consumption of some standard calls.

I measured using the hackatom contract integration tests, as discussed in cosmwasm #314. Noticed an improvement of ~17% for deserialization, and ~10% for serialization. ~27% overall, which is not bad.

webmaster128 commented 3 years ago

Noticed an improvement of ~17% for deserialization, and ~10% for serialization. ~27% overall, which is not bad.

This is good indeed. Since https://github.com/CosmWasm/cosmwasm/pull/379, we charge gas for external API calls, increasing the total gas cost. This happened after https://github.com/CosmWasm/cosmwasm/pull/314. This means the increase/decrease percentages cannot be compared directly anymore.

maurolacy commented 3 years ago

OK, I'll merge this, and create a branch in coswasm to modify the tests / gas limits.

webmaster128 commented 3 years ago

OK, I'll merge this, and create a branch in coswasm to modify the tests / gas limits.

Let me double check one thing now, then I approve

maurolacy commented 3 years ago

Oops, didn't saw your last comment. Let's revert it if you want.