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

feat (encoder): add encoder option NoNullSliceOrMap #218

Merged
merged 9 commits into from Jul 8, 2022
Merged

Conversation

AsterDY
Copy link
Collaborator

@AsterDY AsterDY commented Apr 19, 2022

Benchmark

  • before
goos: darwin
goarch: amd64
pkg: github.com/bytedance/sonic/encoder
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkOptionSliceOrMapNoNull/true-16                 10000000               246.6 ns/op           286 B/op          5 allocs/op
BenchmarkOptionSliceOrMapNoNull/false-16                10000000               247.4 ns/op           288 B/op          5 allocs/op
  • after
goos: darwin
goarch: amd64
pkg: github.com/bytedance/sonic/encoder
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkOptionSliceOrMapNoNull/true-16                 10000000               247.4 ns/op           282 B/op          5 allocs/op
BenchmarkOptionSliceOrMapNoNull/false-16                10000000               236.5 ns/op           283 B/op          5 allocs/op
  • conclusion
    no significant effects on performance

  • interesting discovery
    writing 4 chars (instruction MOVL) is faster than writing 2 chars (instruction MOVW)?

More Benchmarks

go: added golang.org/x/perf v0.0.0-20220411212318-84e58bfe0a7e
name                                     old time/op    new time/op    delta
MarshalConcrete/CanadaGeometry_Sonic-12     724µs ±10%     712µs ± 7%     ~     (p=0.842 n=10+9)
MarshalConcrete/CitmCatalog_Sonic-12        450µs ± 8%     462µs ±21%     ~     (p=0.968 n=9+10)
MarshalConcrete/StringEscaped_Sonic-12     4.53µs ±23%    4.84µs ±12%     ~     (p=0.095 n=9+10)
MarshalConcrete/StringUnicode_Sonic-12     4.95µs ±30%    5.77µs ±40%     ~     (p=0.063 n=10+10)
MarshalConcrete/TwitterStatus_Sonic-12      309µs ±19%     281µs ±20%     ~     (p=0.075 n=10+10)
MarshalConcrete/SyntheaFhir_Sonic-12       8.96ms ± 3%    8.82ms ± 2%   -1.55%  (p=0.036 n=8+9)
MarshalConcrete/GolangSource_Sonic-12      2.29ms ± 7%    2.06ms ± 9%  -10.06%  (p=0.000 n=9+10)

name                                     old speed      new speed      delta
MarshalConcrete/CanadaGeometry_Sonic-12   375MB/s ± 9%   380MB/s ± 6%     ~     (p=0.842 n=10+9)
MarshalConcrete/CitmCatalog_Sonic-12     3.78GB/s ±16%  3.78GB/s ±18%     ~     (p=0.853 n=10+10)
MarshalConcrete/StringEscaped_Sonic-12   9.10GB/s ±29%  8.74GB/s ±12%     ~     (p=0.247 n=10+10)
MarshalConcrete/StringUnicode_Sonic-12   3.74GB/s ±25%  3.24GB/s ±31%     ~     (p=0.063 n=10+10)
MarshalConcrete/TwitterStatus_Sonic-12   2.07GB/s ±17%  2.26GB/s ±17%     ~     (p=0.075 n=10+10)
MarshalConcrete/SyntheaFhir_Sonic-12      224MB/s ± 3%   228MB/s ± 2%   +1.57%  (p=0.036 n=8+9)
MarshalConcrete/GolangSource_Sonic-12     849MB/s ± 8%   945MB/s ± 9%  +11.26%  (p=0.000 n=9+10)

@AsterDY AsterDY merged commit 07d7b86 into main Jul 8, 2022
@AsterDY AsterDY deleted the feat/no_null_arr branch July 8, 2022 07:07
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