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

opt: reduce memory pool size #302

Merged
merged 6 commits into from Oct 28, 2022
Merged

opt: reduce memory pool size #302

merged 6 commits into from Oct 28, 2022

Conversation

liuq19
Copy link
Collaborator

@liuq19 liuq19 commented Sep 23, 2022

performance test (FSM StateMachine shrinkage)

go: added golang.org/x/text v0.3.6
name                                        old time/op    new time/op    delta
UnmarshalConcrete/CanadaGeometry_Sonic-256     925µs ±15%     933µs ±14%    ~     (p=0.841 n=5+5)
UnmarshalConcrete/CitmCatalog_Sonic-256       5.43ms ± 4%    5.65ms ± 9%    ~     (p=0.310 n=5+5)
UnmarshalConcrete/GolangSource_Sonic-256      19.1ms ± 8%    20.2ms ± 9%    ~     (p=0.151 n=5+5)
UnmarshalConcrete/StringEscaped_Sonic-256      104µs ± 8%     107µs ± 3%    ~     (p=0.421 n=5+5)
UnmarshalConcrete/StringUnicode_Sonic-256     14.1µs ±19%    12.8µs ±24%    ~     (p=0.310 n=5+5)
UnmarshalConcrete/SyntheaFhir_Sonic-256       12.9ms ± 5%    13.1ms ± 6%    ~     (p=0.841 n=5+5)
UnmarshalConcrete/TwitterStatus_Sonic-256     2.55ms ± 5%    2.60ms ± 3%    ~     (p=0.548 n=5+5)

name                                        old speed      new speed      delta
UnmarshalConcrete/CanadaGeometry_Sonic-256   296MB/s ±14%   293MB/s ±13%    ~     (p=0.841 n=5+5)
UnmarshalConcrete/CitmCatalog_Sonic-256      319MB/s ± 4%   306MB/s ± 9%    ~     (p=0.310 n=5+5)
UnmarshalConcrete/GolangSource_Sonic-256     102MB/s ± 7%    96MB/s ± 8%    ~     (p=0.151 n=5+5)
UnmarshalConcrete/StringEscaped_Sonic-256    405MB/s ± 8%   392MB/s ± 3%    ~     (p=0.421 n=5+5)
UnmarshalConcrete/StringUnicode_Sonic-256   1.30GB/s ±17%  1.45GB/s ±21%    ~     (p=0.310 n=5+5)
UnmarshalConcrete/SyntheaFhir_Sonic-256      156MB/s ± 5%   153MB/s ± 5%    ~     (p=0.841 n=5+5)
UnmarshalConcrete/TwitterStatus_Sonic-256    248MB/s ± 5%   243MB/s ± 3%    ~     (p=0.548 n=5+5)

name                                        old alloc/op   new alloc/op   delta
UnmarshalConcrete/GolangSource_Sonic-256      20.8MB ± 0%    20.7MB ± 0%  -0.46%  (p=0.008 n=5+5)
UnmarshalConcrete/SyntheaFhir_Sonic-256       10.0MB ± 0%     9.9MB ± 0%  -1.03%  (p=0.008 n=5+5)
UnmarshalConcrete/TwitterStatus_Sonic-256     1.97MB ± 1%    1.93MB ± 0%  -1.65%  (p=0.008 n=5+5)
UnmarshalConcrete/CitmCatalog_Sonic-256       4.95MB ± 1%    4.86MB ± 0%  -1.86%  (p=0.008 n=5+5)
UnmarshalConcrete/CanadaGeometry_Sonic-256     696kB ± 1%     681kB ± 0%  -2.10%  (p=0.008 n=5+5)
UnmarshalConcrete/StringEscaped_Sonic-256      101kB ± 1%      97kB ± 0%  -3.52%  (p=0.008 n=5+5)
UnmarshalConcrete/StringUnicode_Sonic-256     21.9kB ± 1%    20.9kB ± 1%  -4.34%  (p=0.008 n=5+5)

name                                        old allocs/op  new allocs/op  delta
UnmarshalConcrete/TwitterStatus_Sonic-256      1.55k ± 0%     1.56k ± 0%  +0.06%  (p=0.008 n=5+5)
UnmarshalConcrete/GolangSource_Sonic-256       13.1k ± 0%     13.1k ± 0%  +0.04%  (p=0.008 n=5+5)
UnmarshalConcrete/SyntheaFhir_Sonic-256        15.5k ± 0%     15.5k ± 0%  +0.02%  (p=0.016 n=5+4)
UnmarshalConcrete/CitmCatalog_Sonic-256        10.8k ± 0%     10.8k ± 0%  +0.01%  (p=0.016 n=5+4)
UnmarshalConcrete/CanadaGeometry_Sonic-256       567 ± 0%       567 ± 0%    ~     (all equal)
UnmarshalConcrete/StringEscaped_Sonic-256        122 ± 0%       122 ± 0%    ~     (all equal)
UnmarshalConcrete/StringUnicode_Sonic-256       4.00 ± 0%      4.00 ± 0%    ~     (all equal)

@liuq19 liuq19 changed the title fix: reduce state stack size fix: reduce skip's state stack size Sep 27, 2022
@liuq19 liuq19 changed the title fix: reduce skip's state stack size fix: reduce skip's state stack size from 64Kb to 4Kb Sep 27, 2022
@AsterDY
Copy link
Collaborator

AsterDY commented Oct 18, 2022

STD benchmarks (JIT stack shrinkage)

  • CPU
name                           old speed      new speed       delta
pkg:github.com/bytedance/sonic/encoder goos:darwin goarch:amd64
Encoder_Generic_StdLib-16       116MB/s ± 9%    120MB/s ± 2%   +4.01%  (p=0.000 n=98+89)
Encoder_Generic_Sonic-16        369MB/s ± 9%    394MB/s ± 3%   +6.70%  (p=0.000 n=100+98)
pkg:github.com/bytedance/sonic/decoder goos:darwin goarch:amd64
Decoder_Generic_Sonic-16        170MB/s ± 5%    185MB/s ±10%   +8.57%  (p=0.000 n=84+99)
pkg:github.com/bytedance/sonic/encoder goos:darwin goarch:amd64
Encoder_Generic_Sonic_Fast-16   538MB/s ± 5%    585MB/s ± 2%   +8.72%  (p=0.000 n=85+95)
pkg:github.com/bytedance/sonic/decoder goos:darwin goarch:amd64
Decoder_Generic_StdLib-16      89.9MB/s ± 7%  101.0MB/s ± 3%  +12.36%  (p=0.000 n=92+97)
Decoder_Binding_Sonic-16        374MB/s ± 8%    428MB/s ± 2%  +14.30%  (p=0.000 n=100+94)
Decoder_Binding_Sonic_Fast-16   413MB/s ± 1%    473MB/s ± 2%  +14.42%  (p=0.019 n=2+13)
Decoder_Generic_Sonic_Fast-16   209MB/s ± 7%    244MB/s ± 4%  +16.86%  (p=0.000 n=99+96)
pkg:github.com/bytedance/sonic/encoder goos:darwin goarch:amd64
Encoder_Binding_Sonic-16       1.61GB/s ±20%   1.93GB/s ±12%  +20.15%  (p=0.000 n=100+100)
Encoder_Binding_Sonic_Fast-16  1.83GB/s ±17%   2.30GB/s ±10%  +25.49%  (p=0.000 n=84+84)
  • MEM
name                           old alloc/op   new alloc/op    delta
pkg:github.com/bytedance/sonic/decoder goos:darwin goarch:amd64
Decoder_Generic_StdLib-16        50.9kB ± 0%     50.9kB ± 0%     ~     (p=0.625 n=100+99)
pkg:github.com/bytedance/sonic/encoder goos:darwin goarch:amd64
Encoder_Generic_StdLib-16        49.1kB ± 0%     49.1kB ± 0%     ~     (all equal)
pkg:github.com/bytedance/sonic/decoder goos:darwin goarch:amd64
Decoder_Generic_Sonic-16         57.7kB ± 1%     56.8kB ± 0%   -1.62%  (p=0.000 n=99+100)
Decoder_Generic_Sonic_Fast-16    49.9kB ± 1%     49.0kB ± 0%   -1.81%  (p=0.000 n=99+99)
Decoder_Binding_Sonic-16         28.2kB ± 2%     27.3kB ± 0%   -3.27%  (p=0.000 n=99+100)
Decoder_Binding_Sonic_Fast-16    25.3kB ± 1%     24.3kB ± 0%   -3.89%  (p=0.019 n=2+13)
pkg:github.com/bytedance/sonic/encoder goos:darwin goarch:amd64
Encoder_Generic_Sonic-16         12.4kB ±10%     11.2kB ± 1%   -9.57%  (p=0.000 n=98+99)
Encoder_Generic_Sonic_Fast-16    11.6kB ± 6%      9.9kB ± 1%  -14.63%  (p=0.000 n=96+100)
Encoder_Binding_Sonic-16         15.3kB ± 4%     11.9kB ± 2%  -22.58%  (p=0.000 n=99+100)
Encoder_Binding_Sonic_Fast-16    13.5kB ± 6%     10.3kB ± 2%  -23.45%  (p=0.000 n=81+93)

decoder/pools.go Outdated Show resolved Hide resolved
@AsterDY AsterDY changed the title fix: reduce skip's state stack size from 64Kb to 4Kb opt: reduce memory pool size Oct 18, 2022
@AsterDY AsterDY merged commit 6deed01 into main Oct 28, 2022
@AsterDY AsterDY deleted the opt/shorten_stack_depth branch October 28, 2022 08:40
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

3 participants