Skip to content

Conversation

reinkrul
Copy link
Member

@reinkrul reinkrul commented Mar 15, 2025

https://github.com/sugawarayuuta/sonnet

See if it makes a measurable difference. I took the options from https://github.com/go-json-experiment/jsonbench

There's also SonicJSON which is more popular and has similar performance characteristics, but is from ByteDance (not sure if we want to use it). Both use SIMD instructions to speed up unmarshalling.

Also, SonicJSON uses unsafe and assembly, sonnet doesn't (in theory, safer?).

@woutslakhorst
Copy link
Member

I would prefer to remove (un)marshalling steps where not needed in the code before changing the library.

@gerardsn
Copy link
Member

If we are switching the library I'd also prefer to use json/v2. It's not the fastest, but comparable with the others and I prefer using the std lib over external deps. Or is there a reason to switch to a different lib?

@reinkrul
Copy link
Member Author

If we are switching the library I'd also prefer to use json/v2. It's not the fastest, but comparable with the others and I prefer using the std lib over external deps. Or is there a reason to switch to a different lib?

It's unclear what happens to json/v2, they stated an outcome might be that they discontinue it if it doesn't provide the expected benefits. Although json/v2 is preferred if it's ultimately adopted in the stdlib. Although sonnet is faster, according to their own benchmarks.

But, I just wanted to test whether it's feasible to replace it and what the performance gains are. But I agree with Wout that we should simplify things first (less marshalling).

@reinkrul
Copy link
Member Author

Test e2e-tests/nuts-network/private-transactions is performed using #3753 on my local system. This test performs 40 iterations, and it sleeps 1 second in each iteration. So 40 seconds needs to be retracted for wait time.

  • Baseline (20bdc8f4725ff1073b93fec20aa2f1ea5345a0e4) completes in 56~57 seconds
  • This PR (d8d226a3b18fb873a49201adc1db040d90115601) completes in 57 seconds

No measurable benefit.

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.

3 participants