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 Encoder.WriteValue for object names #68

Merged
merged 1 commit into from
Dec 8, 2024
Merged

Conversation

dsnet
Copy link
Collaborator

@dsnet dsnet commented Dec 8, 2024

By specifying the isVerbatim flag to names.insertQuoted, the method can avoid unquoting the name since it knows that it only needs to strip off the surrounding double quotes.

Performance:

name                                           old speed      new speed      delta
Testdata/CanadaGeometry/Encode/Value/Buffered  1.12GB/s ± 0%  1.15GB/s ± 3%     ~     (p=0.151 n=5+5)
Testdata/CitmCatalog/Encode/Value/Buffered     1.76GB/s ± 0%  1.99GB/s ± 1%  +13.19%  (p=0.008 n=5+5)
Testdata/GolangSource/Encode/Value/Buffered     793MB/s ± 4%   949MB/s ± 1%  +19.68%  (p=0.008 n=5+5)
Testdata/StringEscaped/Encode/Value/Buffered    228MB/s ± 1%   229MB/s ± 0%     ~     (p=0.421 n=5+5)
Testdata/StringUnicode/Encode/Value/Buffered    983MB/s ± 0%  1014MB/s ± 1%   +3.12%  (p=0.008 n=5+5)
Testdata/SyntheaFhir/Encode/Value/Buffered     1.39GB/s ± 4%  1.65GB/s ± 1%  +18.43%  (p=0.008 n=5+5)
Testdata/TwitterStatus/Encode/Value/Buffered   1.03GB/s ± 1%  1.23GB/s ± 0%  +19.81%  (p=0.008 n=5+5)

By specifying the isVerbatim flag to names.insertQuoted,
the method can avoid unquoting the name since it knows that
it only needs to strip off the surrounding double quotes.

Performance:

    name                                           old speed      new speed      delta
    Testdata/CanadaGeometry/Encode/Value/Buffered  1.12GB/s ± 0%  1.15GB/s ± 3%     ~     (p=0.151 n=5+5)
    Testdata/CitmCatalog/Encode/Value/Buffered     1.76GB/s ± 0%  1.99GB/s ± 1%  +13.19%  (p=0.008 n=5+5)
    Testdata/GolangSource/Encode/Value/Buffered     793MB/s ± 4%   949MB/s ± 1%  +19.68%  (p=0.008 n=5+5)
    Testdata/StringEscaped/Encode/Value/Buffered    228MB/s ± 1%   229MB/s ± 0%     ~     (p=0.421 n=5+5)
    Testdata/StringUnicode/Encode/Value/Buffered    983MB/s ± 0%  1014MB/s ± 1%   +3.12%  (p=0.008 n=5+5)
    Testdata/SyntheaFhir/Encode/Value/Buffered     1.39GB/s ± 4%  1.65GB/s ± 1%  +18.43%  (p=0.008 n=5+5)
    Testdata/TwitterStatus/Encode/Value/Buffered   1.03GB/s ± 1%  1.23GB/s ± 0%  +19.81%  (p=0.008 n=5+5)
@dsnet dsnet force-pushed the encode-value-verbatim branch from 3800200 to 0984d1e Compare December 8, 2024 00:46
Copy link
Collaborator

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

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

Very impressive fix

@dsnet dsnet merged commit d0ded75 into master Dec 8, 2024
8 checks passed
@dsnet dsnet deleted the encode-value-verbatim branch December 8, 2024 08:19
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.

2 participants