Skip to content
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

Upgrade JSON library #314

Merged
merged 8 commits into from
May 7, 2020
Merged

Upgrade JSON library #314

merged 8 commits into from
May 7, 2020

Conversation

webmaster128
Copy link
Member

@webmaster128 webmaster128 commented May 6, 2020

Closes #110
Closes #312

  • Integrate new version of serde-json-wasm
  • Publish serde-json-wasm 0.2.0 and use from crates.io

@webmaster128 webmaster128 requested a review from ethanfrey May 6, 2020 15:07
@webmaster128
Copy link
Member Author

This is done as far as I can see

Copy link
Member

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, please merge and tag.

I created CosmWasm/serde-json-wasm#16 to be done either in 0.8.0 or 0.8.1. No rush on it, but don't want to forget it.

@@ -339,8 +339,9 @@ mod singlepass_tests {
// Gas consumtion is relatively small
// Note: the exact gas usage depends on the Rust version used to compile WASM,
// which we only fix when using cosmwasm-opt, not integration tests.
assert!(gas_used > 26000, "{}", gas_used);
assert!(gas_used < 30000, "{}", gas_used);
let expected = 42000; // +/- 20%
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, this increased gas usage a lot! (+/- 28k to +/- 42k)

Maybe it makes sense to have a hot-path when there is no escaped characters inside the string to just do the old copy. We can merge this, but it would be nice to update the json lib before 0.8 (we can do that in a week or so, but it should be possible to do around the same cost when there are no escapes)

}

#[test]
fn to_vec_works_for_special_chars() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. These two

@@ -393,7 +393,7 @@ mod singlepass_test {

let init_used = orig_gas - instance.get_gas();
println!("init used: {}", init_used);
assert_eq!(init_used, 45568);
assert_eq!(init_used, 65606);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are all quite huge gas increases for the safety check. I'm sure this can be optimized. But like I said, in a point release of serde-json-wasm, maybe in cosmwasm 0.8.1. This is an optimization that doesn't break any APIs

@webmaster128 webmaster128 merged commit 4e1631c into master May 7, 2020
@webmaster128 webmaster128 deleted the json-upgrade branch May 7, 2020 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reconsider or fix json lib
2 participants