Skip to content

Only use the token queue for fields we really can't parse immediately#628

Merged
slinkydeveloper merged 3 commits intocloudevents:masterfrom
markusthoemmes:less-queue
Nov 26, 2020
Merged

Only use the token queue for fields we really can't parse immediately#628
slinkydeveloper merged 3 commits intocloudevents:masterfrom
markusthoemmes:less-queue

Conversation

@markusthoemmes
Copy link
Copy Markdown
Contributor

@markusthoemmes markusthoemmes commented Nov 26, 2020

Most of the keys are parsed identically between the versions, so why bother deferring their parsing and allocating stuff unnecessarily? This also puts an upper bound on the tokenQueue in theory.

Signed-off-by: Markus Thömmes markusthoemmes@me.com

Benchmark

name                                                                                old time/op    new time/op    delta
Unmarshal/struct_data_v0.3-16                                                         16.3µs ± 0%    16.4µs ± 1%   +0.75%  (p=0.032 n=5+5)
Unmarshal/nil_data_v0.3-16                                                            14.8µs ± 0%    14.9µs ± 1%   +0.73%  (p=0.016 n=5+5)
Unmarshal/struct_data_v1.0-16                                                         16.1µs ± 1%    16.3µs ± 1%     ~     (p=0.056 n=5+5)
Unmarshal/data,_attributes_and_extensions_and_specversion_with_struct_data_v1.0-16    18.0µs ± 1%    17.3µs ± 1%   -4.10%  (p=0.008 n=5+5)
Unmarshal/string_data_v1.0-16                                                         15.8µs ± 1%    15.9µs ± 1%     ~     (p=0.310 n=5+5)
Unmarshal/base64_json_encoded_data_v1.0-16                                            11.3µs ± 1%    11.4µs ± 1%     ~     (p=0.310 n=5+5)
Unmarshal/base64_xml_encoded_data_v1.0-16                                             11.8µs ± 1%    11.8µs ± 1%     ~     (p=0.548 n=5+5)
Unmarshal/string_data_v0.3-16                                                         15.8µs ± 1%    16.0µs ± 1%   +1.35%  (p=0.016 n=5+5)
Unmarshal/data,_attributes_and_extensions_and_specversion_with_struct_data_v0.3-16    17.8µs ± 0%    17.0µs ± 1%   -4.51%  (p=0.008 n=5+5)
Unmarshal/nil_data_v1.0-16                                                            15.0µs ± 1%    15.2µs ± 1%     ~     (p=0.095 n=5+5)

name                                                                                old alloc/op   new alloc/op   delta
Unmarshal/struct_data_v0.3-16                                                         3.37kB ± 0%    3.37kB ± 0%     ~     (all equal)
Unmarshal/nil_data_v0.3-16                                                            3.14kB ± 0%    3.14kB ± 0%     ~     (all equal)
Unmarshal/struct_data_v1.0-16                                                         3.20kB ± 0%    3.20kB ± 0%     ~     (all equal)
Unmarshal/data,_attributes_and_extensions_and_specversion_with_struct_data_v1.0-16    3.69kB ± 0%    3.45kB ± 0%   -6.53%  (p=0.008 n=5+5)
Unmarshal/string_data_v1.0-16                                                         3.18kB ± 0%    3.18kB ± 0%     ~     (all equal)
Unmarshal/base64_json_encoded_data_v1.0-16                                            2.66kB ± 0%    2.66kB ± 0%     ~     (all equal)
Unmarshal/base64_xml_encoded_data_v1.0-16                                             2.67kB ± 0%    2.67kB ± 0%     ~     (all equal)
Unmarshal/string_data_v0.3-16                                                         3.36kB ± 0%    3.36kB ± 0%     ~     (all equal)
Unmarshal/data,_attributes_and_extensions_and_specversion_with_struct_data_v0.3-16    3.69kB ± 0%    3.45kB ± 0%   -6.53%  (p=0.008 n=5+5)
Unmarshal/nil_data_v1.0-16                                                            3.14kB ± 0%    3.14kB ± 0%     ~     (all equal)

name                                                                                old allocs/op  new allocs/op  delta
Unmarshal/struct_data_v0.3-16                                                           68.0 ± 0%      68.0 ± 0%     ~     (all equal)
Unmarshal/nil_data_v0.3-16                                                              63.0 ± 0%      63.0 ± 0%     ~     (all equal)
Unmarshal/struct_data_v1.0-16                                                           66.0 ± 0%      66.0 ± 0%     ~     (all equal)
Unmarshal/data,_attributes_and_extensions_and_specversion_with_struct_data_v1.0-16      82.0 ± 0%      70.0 ± 0%  -14.63%  (p=0.008 n=5+5)
Unmarshal/string_data_v1.0-16                                                           65.0 ± 0%      65.0 ± 0%     ~     (all equal)
Unmarshal/base64_json_encoded_data_v1.0-16                                              48.0 ± 0%      48.0 ± 0%     ~     (all equal)
Unmarshal/base64_xml_encoded_data_v1.0-16                                               48.0 ± 0%      48.0 ± 0%     ~     (all equal)
Unmarshal/string_data_v0.3-16                                                           67.0 ± 0%      67.0 ± 0%     ~     (all equal)
Unmarshal/data,_attributes_and_extensions_and_specversion_with_struct_data_v0.3-16      82.0 ± 0%      70.0 ± 0%  -14.63%  (p=0.008 n=5+5)
Unmarshal/nil_data_v1.0-16                                                              63.0 ± 0%      63.0 ± 0%     ~     (all equal)

Signed-off-by: Markus Thömmes <markusthoemmes@me.com>
Copy link
Copy Markdown
Member

@slinkydeveloper slinkydeveloper left a comment

Choose a reason for hiding this comment

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

Can you run with count=5 and benchtime=5s? I would love to check if the time difference is simple noise over the different runs

Signed-off-by: Markus Thömmes <markusthoemmes@me.com>
Signed-off-by: Markus Thömmes <markusthoemmes@me.com>
@slinkydeveloper slinkydeveloper merged commit 0cefc28 into cloudevents:master Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants