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

Optimize JSON parsing #439

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Optimize JSON parsing #439

wants to merge 3 commits into from

Conversation

S7evinK
Copy link
Contributor

@S7evinK S7evinK commented Oct 3, 2024

Based on neilalexander/harmony@586b083 with minor changes.

Benchstat vs main:

goos: linux
goarch: amd64
pkg: github.com/matrix-org/gomatrixserverlib
cpu: Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
                              │   old.txt    │               new.txt                │
                              │    sec/op    │    sec/op     vs base                │
ParseLargerEvent-8               56.98µ ± 5%   49.62µ ±  3%  -12.91% (p=0.000 n=10)
ParseSmallerEvent-8              52.12µ ± 5%   47.13µ ± 14%   -9.58% (p=0.019 n=10)
ParseSmallerEventFailedHash-8   109.01µ ± 6%   98.07µ ±  4%  -10.04% (p=0.000 n=10)
ParseSmallerEventRedacted-8      83.67µ ± 3%   73.17µ ±  3%  -12.56% (p=0.000 n=10)
geomean                          72.14µ        64.00µ        -11.28%

                              │   old.txt    │               new.txt                │
                              │     B/op     │     B/op      vs base                │
ParseLargerEvent-8              29.17Ki ± 0%   16.75Ki ± 0%  -42.58% (p=0.000 n=10)
ParseSmallerEvent-8             23.25Ki ± 0%   16.16Ki ± 0%  -30.51% (p=0.000 n=10)
ParseSmallerEventFailedHash-8   40.19Ki ± 0%   26.05Ki ± 0%  -35.18% (p=0.000 n=10)
ParseSmallerEventRedacted-8     33.75Ki ± 0%   19.69Ki ± 0%  -41.65% (p=0.000 n=10)
geomean                         30.97Ki        19.30Ki       -37.67%

                              │  old.txt   │              new.txt               │
                              │ allocs/op  │ allocs/op   vs base                │
ParseLargerEvent-8              209.0 ± 0%   126.0 ± 0%  -39.71% (p=0.000 n=10)
ParseSmallerEvent-8             192.0 ± 0%   132.0 ± 0%  -31.25% (p=0.000 n=10)
ParseSmallerEventFailedHash-8   380.0 ± 0%   263.0 ± 0%  -30.79% (p=0.000 n=10)
ParseSmallerEventRedacted-8     282.0 ± 0%   168.0 ± 0%  -40.43% (p=0.000 n=10)
geomean                         256.1        164.6       -35.70%

@S7evinK
Copy link
Contributor Author

S7evinK commented Oct 3, 2024

Going to ignore the linter errors for now, those should be fixed in a different PR.

Co-authored-by: Neil Alexander <[email protected]>
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.

1 participant