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

encoding/json: optimize tag parsing by introducing cutTag helper function #67100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aimuz
Copy link
Contributor

@aimuz aimuz commented Apr 29, 2024

Refactor tag parsing in json encoding to use a new helper function, cutTag,
improving readability and potentially enhancing performance.

goos: darwin
goarch: arm64
pkg: encoding/json
cpu: Apple M2 Max
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
CodeEncoder-12 330.4µ ± 5% 342.0µ ± 6% ~ (p=0.393 n=10)
CodeEncoderError-12 403.9µ ± 8% 342.5µ ± 5% -15.21% (p=0.000 n=10)
CodeMarshal-12 429.6µ ± 6% 407.3µ ± 7% -5.17% (p=0.043 n=10)
CodeMarshalError-12 486.5µ ± 5% 481.5µ ± 5% ~ (p=0.105 n=10)
CodeDecoder-12 1.806m ± 6% 1.783m ± 6% ~ (p=0.247 n=10)
CodeUnmarshal-12 2.308m ± 1% 2.269m ± 8% ~ (p=0.315 n=10)
CodeUnmarshalReuse-12 1.805m ± 5% 1.791m ± 6% ~ (p=0.739 n=10)
geomean 800.0µ 774.0µ -3.25%

                  │   old.txt    │               new.txt                │
                  │     B/s      │     B/s       vs base                │

CodeEncoder-12 5.470Gi ± 5% 5.284Gi ± 6% ~ (p=0.393 n=10)
CodeEncoderError-12 4.475Gi ± 7% 5.277Gi ± 4% +17.93% (p=0.000 n=10)
CodeMarshal-12 4.207Gi ± 6% 4.437Gi ± 8% +5.47% (p=0.043 n=10)
CodeMarshalError-12 3.715Gi ± 5% 3.753Gi ± 5% ~ (p=0.105 n=10)
CodeDecoder-12 1.001Gi ± 5% 1.014Gi ± 5% ~ (p=0.247 n=10)
CodeUnmarshal-12 801.8Mi ± 1% 815.6Mi ± 8% ~ (p=0.315 n=10)
CodeUnmarshalReuse-12 1.001Gi ± 5% 1.009Gi ± 5% ~ (p=0.739 n=10)
geomean 2.259Gi 2.335Gi +3.36%

                  │   old.txt    │               new.txt                │
                  │     B/op     │     B/op      vs base                │

CodeEncoder-12 1.000 ± ? 2.000 ± ? ~ (p=0.534 n=10)
CodeEncoderError-12 138.0 ± 1% 137.0 ± 1% ~ (p=0.440 n=10)
CodeMarshal-12 1.855Mi ± 1% 1.856Mi ± 1% ~ (p=0.853 n=10)
CodeMarshalError-12 1.889Mi ± 1% 1.893Mi ± 1% ~ (p=0.631 n=10)
CodeDecoder-12 822.1Ki ± 1% 823.8Ki ± 1% ~ (p=0.739 n=10)
CodeUnmarshal-12 1.917Mi ± 0% 1.918Mi ± 0% ~ (p=0.064 n=10)
CodeUnmarshalReuse-12 711.9Ki ± 0% 712.5Ki ± 0% ~ (p=0.085 n=10)
geomean 47.63Ki 52.57Ki +10.38%

                  │    old.txt    │               new.txt                │
                  │   allocs/op   │  allocs/op   vs base                 │

CodeEncoder-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
CodeEncoderError-12 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹
CodeMarshal-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
CodeMarshalError-12 6.000 ± 0% 6.000 ± 0% ~ (p=1.000 n=10) ¹
CodeDecoder-12 25.20k ± 0% 25.20k ± 0% ~ (p=0.699 n=10)
CodeUnmarshal-12 39.99k ± 0% 39.99k ± 0% ~ (p=1.000 n=10) ¹
CodeUnmarshalReuse-12 25.21k ± 0% 25.22k ± 0% ~ (p=0.093 n=10)
geomean ² +0.01% ²
¹ all samples are equal
² summaries must be >0 to compute geomean

…tion

Refactor tag parsing in json encoding to use a new helper function, cutTag,
improving readability and potentially enhancing performance.

goos: darwin
goarch: arm64
pkg: encoding/json
cpu: Apple M2 Max
                      │   old.txt   │               new.txt               │
                      │   sec/op    │   sec/op     vs base                │
CodeEncoder-12          330.4µ ± 5%   342.0µ ± 6%        ~ (p=0.393 n=10)
CodeEncoderError-12     403.9µ ± 8%   342.5µ ± 5%  -15.21% (p=0.000 n=10)
CodeMarshal-12          429.6µ ± 6%   407.3µ ± 7%   -5.17% (p=0.043 n=10)
CodeMarshalError-12     486.5µ ± 5%   481.5µ ± 5%        ~ (p=0.105 n=10)
CodeDecoder-12          1.806m ± 6%   1.783m ± 6%        ~ (p=0.247 n=10)
CodeUnmarshal-12        2.308m ± 1%   2.269m ± 8%        ~ (p=0.315 n=10)
CodeUnmarshalReuse-12   1.805m ± 5%   1.791m ± 6%        ~ (p=0.739 n=10)
geomean                 800.0µ        774.0µ        -3.25%

                      │   old.txt    │               new.txt                │
                      │     B/s      │     B/s       vs base                │
CodeEncoder-12          5.470Gi ± 5%   5.284Gi ± 6%        ~ (p=0.393 n=10)
CodeEncoderError-12     4.475Gi ± 7%   5.277Gi ± 4%  +17.93% (p=0.000 n=10)
CodeMarshal-12          4.207Gi ± 6%   4.437Gi ± 8%   +5.47% (p=0.043 n=10)
CodeMarshalError-12     3.715Gi ± 5%   3.753Gi ± 5%        ~ (p=0.105 n=10)
CodeDecoder-12          1.001Gi ± 5%   1.014Gi ± 5%        ~ (p=0.247 n=10)
CodeUnmarshal-12        801.8Mi ± 1%   815.6Mi ± 8%        ~ (p=0.315 n=10)
CodeUnmarshalReuse-12   1.001Gi ± 5%   1.009Gi ± 5%        ~ (p=0.739 n=10)
geomean                 2.259Gi        2.335Gi        +3.36%

                      │   old.txt    │               new.txt                │
                      │     B/op     │     B/op      vs base                │
CodeEncoder-12            1.000 ±  ?     2.000 ±  ?        ~ (p=0.534 n=10)
CodeEncoderError-12       138.0 ± 1%     137.0 ± 1%        ~ (p=0.440 n=10)
CodeMarshal-12          1.855Mi ± 1%   1.856Mi ± 1%        ~ (p=0.853 n=10)
CodeMarshalError-12     1.889Mi ± 1%   1.893Mi ± 1%        ~ (p=0.631 n=10)
CodeDecoder-12          822.1Ki ± 1%   823.8Ki ± 1%        ~ (p=0.739 n=10)
CodeUnmarshal-12        1.917Mi ± 0%   1.918Mi ± 0%        ~ (p=0.064 n=10)
CodeUnmarshalReuse-12   711.9Ki ± 0%   712.5Ki ± 0%        ~ (p=0.085 n=10)
geomean                 47.63Ki        52.57Ki       +10.38%

                      │    old.txt    │               new.txt                │
                      │   allocs/op   │  allocs/op   vs base                 │
CodeEncoder-12           0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=10) ¹
CodeEncoderError-12      4.000 ± 0%      4.000 ± 0%       ~ (p=1.000 n=10) ¹
CodeMarshal-12           1.000 ± 0%      1.000 ± 0%       ~ (p=1.000 n=10) ¹
CodeMarshalError-12      6.000 ± 0%      6.000 ± 0%       ~ (p=1.000 n=10) ¹
CodeDecoder-12          25.20k ± 0%     25.20k ± 0%       ~ (p=0.699 n=10)
CodeUnmarshal-12        39.99k ± 0%     39.99k ± 0%       ~ (p=1.000 n=10) ¹
CodeUnmarshalReuse-12   25.21k ± 0%     25.22k ± 0%       ~ (p=0.093 n=10)
geomean                             ²                +0.01%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
@gopherbot
Copy link

This PR (HEAD: ad9c864) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/go/+/582295.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot
Copy link

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Zhen Li:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from qiulaidongfeng:

Patch Set 1: Code-Review+1 Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 1:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2024-04-29T11:03:29Z","revision":"53fa18743c63077424a8af9aac9e2e78c951dc5d"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Daniel Martí:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from qiulaidongfeng:

Patch Set 1: -Commit-Queue


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 1:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Go LUCI:

Patch Set 1: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

@gopherbot
Copy link

Message from Zhen Li:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/582295.
After addressing review feedback, remember to publish your drafts!

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.

None yet

2 participants