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

Decode: slices specialization #669

Draft
wants to merge 6 commits into
base: v2
Choose a base branch
from
Draft

Decode: slices specialization #669

wants to merge 6 commits into from

Conversation

pelletier
Copy link
Owner

Taking a shot at specializing unmarshal code to work on concrete types instead of fully in reflect land.

At the moment I experimented with UnmarshalArray, as it has simpler semantics than the rest. I only specialized unmarshaling into []interface{}.

Results are quite encouraging!


name                               old time/op    new time/op     delta
UnmarshalDataset/config-2            24.3ms ± 1%     24.0ms ± 0%   -1.06%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2            85.8ms ± 0%     66.2ms ± 0%  -22.87%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2      27.2ms ± 3%     25.5ms ± 0%   -6.29%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2           10.8ms ± 2%     10.8ms ± 2%     ~     (p=0.548 n=5+5)
UnmarshalDataset/code-2               107ms ± 1%      108ms ± 7%     ~     (p=0.841 n=5+5)
UnmarshalDataset/example-2            181µs ± 2%      177µs ± 0%   -2.15%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2     530ns ± 1%      542ns ± 0%   +2.23%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2        807ns ± 1%      812ns ± 0%     ~     (p=0.151 n=5+5)
Unmarshal/ReferenceFile/struct-2     53.6µs ± 2%     52.2µs ± 0%   -2.69%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2        82.5µs ± 0%     79.7µs ± 0%   -3.46%  (p=0.016 n=4+5)
Unmarshal/HugoFrontMatter-2          14.6µs ± 3%     13.6µs ± 0%   -6.31%  (p=0.008 n=5+5)

name                               old speed      new speed       delta
UnmarshalDataset/config-2          43.1MB/s ± 1%   43.6MB/s ± 0%   +1.08%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2          25.7MB/s ± 0%   33.3MB/s ± 0%  +29.66%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2    20.6MB/s ± 3%   21.9MB/s ± 0%   +6.68%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2         40.9MB/s ± 2%   40.8MB/s ± 2%     ~     (p=0.548 n=5+5)
UnmarshalDataset/code-2            25.0MB/s ± 1%   24.8MB/s ± 6%     ~     (p=0.841 n=5+5)
UnmarshalDataset/example-2         44.7MB/s ± 2%   45.7MB/s ± 0%   +2.20%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2  20.8MB/s ± 1%   20.3MB/s ± 0%   -2.19%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2     13.6MB/s ± 1%   13.5MB/s ± 0%     ~     (p=0.159 n=5+5)
Unmarshal/ReferenceFile/struct-2   97.8MB/s ± 2%  100.5MB/s ± 0%   +2.74%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2      63.5MB/s ± 0%   65.8MB/s ± 0%   +3.59%  (p=0.016 n=4+5)
Unmarshal/HugoFrontMatter-2        37.5MB/s ± 3%   40.0MB/s ± 0%   +6.71%  (p=0.008 n=5+5)

name                               old alloc/op   new alloc/op    delta
UnmarshalDataset/config-2            5.92MB ± 0%     5.85MB ± 0%   -1.05%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2            84.4MB ± 0%     77.3MB ± 0%   -8.34%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2      35.8MB ± 0%     35.3MB ± 0%   -1.33%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2           13.5MB ± 0%     13.5MB ± 0%   -0.17%  (p=0.008 n=5+5)
UnmarshalDataset/code-2              22.3MB ± 0%     22.3MB ± 0%     ~     (p=0.135 n=5+5)
UnmarshalDataset/example-2            205kB ± 0%      204kB ± 0%   -0.55%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2      581B ± 0%       581B ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-2         957B ± 0%       957B ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/struct-2     20.8kB ± 0%     20.5kB ± 0%   -1.46%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2        38.1kB ± 0%     37.1kB ± 0%   -2.62%  (p=0.000 n=4+5)
Unmarshal/HugoFrontMatter-2          7.38kB ± 0%     7.14kB ± 0%   -3.25%  (p=0.008 n=5+5)

name                               old allocs/op  new allocs/op   delta
UnmarshalDataset/config-2              233k ± 0%       230k ± 0%   -1.33%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2              782k ± 0%       447k ± 0%  -42.78%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2        192k ± 0%       169k ± 0%  -12.38%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2            56.9k ± 0%      55.8k ± 0%   -2.00%  (p=0.008 n=5+5)
UnmarshalDataset/code-2               1.06M ± 0%      1.06M ± 0%     ~     (all equal)
UnmarshalDataset/example-2            1.36k ± 0%      1.31k ± 0%   -4.10%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2      7.00 ± 0%       7.00 ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-2         12.0 ± 0%       12.0 ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/struct-2        182 ± 0%        167 ± 0%   -8.24%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2           649 ± 0%        599 ± 0%   -7.70%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2             143 ± 0%        131 ± 0%   -8.39%  (p=0.008 n=5+5)

@pelletier
Copy link
Owner Author

Implemented a specialized generator that works for any slice type. Though this works well on benchmarks that use multiple slice types (ReferenceFile/struct), there is a bit of overhead for the others that basically just use []interface{}:

Given TOML is often use in short lived programs (interactive CLI), it probably worth considering keeping a separate function just for the popular []interface{} to avoid any extra allocation (the cache and the specialized function) for such programs.


name                               old time/op    new time/op     delta
UnmarshalDataset/config-2            24.3ms ± 1%     24.9ms ± 0%   +2.27%  (p=0.016 n=5+4)
UnmarshalDataset/canada-2            85.8ms ± 0%     66.3ms ± 0%  -22.77%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2      27.2ms ± 3%     25.0ms ± 0%   -8.06%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2           10.8ms ± 2%     10.8ms ± 2%     ~     (p=1.000 n=5+5)
UnmarshalDataset/code-2               107ms ± 1%      108ms ± 0%     ~     (p=0.151 n=5+5)
UnmarshalDataset/example-2            181µs ± 2%      176µs ± 0%   -2.70%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2     530ns ± 1%      579ns ± 0%   +9.21%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2        807ns ± 1%      867ns ± 0%   +7.44%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2     53.6µs ± 2%     49.5µs ± 0%   -7.67%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2        82.5µs ± 0%     80.3µs ± 0%   -2.68%  (p=0.016 n=4+5)
Unmarshal/HugoFrontMatter-2          14.6µs ± 3%     13.9µs ± 0%   -4.67%  (p=0.008 n=5+5)

name                               old speed      new speed       delta
UnmarshalDataset/config-2          43.1MB/s ± 1%   42.2MB/s ± 0%   -2.22%  (p=0.016 n=5+4)
UnmarshalDataset/canada-2          25.7MB/s ± 0%   33.2MB/s ± 0%  +29.50%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2    20.6MB/s ± 3%   22.3MB/s ± 0%   +8.71%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2         40.9MB/s ± 2%   40.9MB/s ± 2%     ~     (p=1.000 n=5+5)
UnmarshalDataset/code-2            25.0MB/s ± 1%   24.8MB/s ± 0%     ~     (p=0.151 n=5+5)
UnmarshalDataset/example-2         44.7MB/s ± 2%   45.9MB/s ± 0%   +2.76%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2  20.8MB/s ± 1%   19.0MB/s ± 0%   -8.42%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2     13.6MB/s ± 1%   12.7MB/s ± 0%   -6.96%  (p=0.016 n=5+4)
Unmarshal/ReferenceFile/struct-2   97.8MB/s ± 2%  105.9MB/s ± 0%   +8.28%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2      63.5MB/s ± 0%   65.3MB/s ± 0%   +2.75%  (p=0.016 n=4+5)
Unmarshal/HugoFrontMatter-2        37.5MB/s ± 3%   39.3MB/s ± 0%   +4.87%  (p=0.008 n=5+5)

name                               old alloc/op   new alloc/op    delta
UnmarshalDataset/config-2            5.92MB ± 0%     5.85MB ± 0%   -1.05%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2            84.4MB ± 0%     76.6MB ± 0%   -9.25%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2      35.8MB ± 0%     35.3MB ± 0%   -1.33%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2           13.5MB ± 0%     13.5MB ± 0%   -0.16%  (p=0.008 n=5+5)
UnmarshalDataset/code-2              22.3MB ± 0%     22.3MB ± 0%   +0.00%  (p=0.008 n=5+5)
UnmarshalDataset/example-2            205kB ± 0%      204kB ± 0%   -0.48%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2      581B ± 0%       709B ± 0%  +22.03%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2         957B ± 0%      1085B ± 0%  +13.38%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2     20.8kB ± 0%     19.8kB ± 0%   -4.74%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2        38.1kB ± 0%     37.3kB ± 0%   -2.29%  (p=0.029 n=4+4)
Unmarshal/HugoFrontMatter-2          7.38kB ± 0%     7.26kB ± 0%   -1.52%  (p=0.008 n=5+5)

name                               old allocs/op  new allocs/op   delta
UnmarshalDataset/config-2              233k ± 0%       230k ± 0%   -1.33%  (p=0.000 n=5+4)
UnmarshalDataset/canada-2              782k ± 0%       447k ± 0%  -42.78%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2        192k ± 0%       169k ± 0%  -12.38%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2            56.9k ± 0%      55.8k ± 0%   -1.99%  (p=0.008 n=5+5)
UnmarshalDataset/code-2               1.06M ± 0%      1.06M ± 0%   +0.00%  (p=0.008 n=5+5)
UnmarshalDataset/example-2            1.36k ± 0%      1.31k ± 0%   -4.03%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2      7.00 ± 0%       8.00 ± 0%  +14.29%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2         12.0 ± 0%       13.0 ± 0%   +8.33%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2        182 ± 0%        125 ± 0%  -31.32%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2           649 ± 0%        600 ± 0%   -7.55%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2             143 ± 0%        132 ± 0%   -7.69%  (p=0.008 n=5+5)

@pelletier
Copy link
Owner Author

name                               old time/op    new time/op     delta
UnmarshalDataset/config-2            24.3ms ± 1%     24.7ms ± 0%   +1.66%  (p=0.016 n=5+4)
UnmarshalDataset/canada-2            85.8ms ± 0%     62.5ms ± 1%  -27.20%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2      27.2ms ± 3%     24.2ms ± 2%  -11.01%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2           10.8ms ± 2%     10.7ms ± 0%     ~     (p=0.151 n=5+5)
UnmarshalDataset/code-2               107ms ± 1%      106ms ± 0%   -1.02%  (p=0.032 n=5+5)
UnmarshalDataset/example-2            181µs ± 2%      173µs ± 0%   -4.54%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2     530ns ± 1%      566ns ± 0%   +6.72%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2        807ns ± 1%      869ns ± 0%   +7.65%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2     53.6µs ± 2%     49.0µs ± 0%   -8.51%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2        82.5µs ± 0%     78.8µs ± 0%   -4.53%  (p=0.016 n=4+5)
Unmarshal/HugoFrontMatter-2          14.6µs ± 3%     13.6µs ± 0%   -6.91%  (p=0.008 n=5+5)

name                               old speed      new speed       delta
UnmarshalDataset/config-2          43.1MB/s ± 1%   42.4MB/s ± 0%   -1.63%  (p=0.016 n=5+4)
UnmarshalDataset/canada-2          25.7MB/s ± 0%   35.2MB/s ± 1%  +37.37%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2    20.6MB/s ± 3%   23.1MB/s ± 2%  +12.34%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2         40.9MB/s ± 2%   41.3MB/s ± 0%     ~     (p=0.151 n=5+5)
UnmarshalDataset/code-2            25.0MB/s ± 1%   25.3MB/s ± 0%   +1.02%  (p=0.032 n=5+5)
UnmarshalDataset/example-2         44.7MB/s ± 2%   46.8MB/s ± 0%   +4.75%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2  20.8MB/s ± 1%   19.4MB/s ± 0%   -6.30%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2     13.6MB/s ± 1%   12.7MB/s ± 0%   -7.09%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2   97.8MB/s ± 2%  106.9MB/s ± 0%   +9.27%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2      63.5MB/s ± 0%   66.5MB/s ± 0%   +4.74%  (p=0.016 n=4+5)
Unmarshal/HugoFrontMatter-2        37.5MB/s ± 3%   40.3MB/s ± 0%   +7.40%  (p=0.008 n=5+5)

name                               old alloc/op   new alloc/op    delta
UnmarshalDataset/config-2            5.92MB ± 0%     5.85MB ± 0%   -1.05%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2            84.4MB ± 0%     75.2MB ± 0%  -10.84%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2      35.8MB ± 0%     35.0MB ± 0%   -2.03%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2           13.5MB ± 0%     13.5MB ± 0%   -0.35%  (p=0.008 n=5+5)
UnmarshalDataset/code-2              22.3MB ± 0%     22.0MB ± 0%   -1.30%  (p=0.008 n=5+5)
UnmarshalDataset/example-2            205kB ± 0%      203kB ± 0%   -0.83%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2      581B ± 0%       709B ± 0%  +22.03%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2         957B ± 0%      1085B ± 0%  +13.38%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2     20.8kB ± 0%     19.7kB ± 0%   -4.97%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2        38.1kB ± 0%     37.0kB ± 0%   -2.92%  (p=0.029 n=4+4)
Unmarshal/HugoFrontMatter-2          7.38kB ± 0%     7.22kB ± 0%   -2.17%  (p=0.008 n=5+5)

name                               old allocs/op  new allocs/op   delta
UnmarshalDataset/config-2              233k ± 0%       230k ± 0%   -1.33%  (p=0.000 n=5+4)
UnmarshalDataset/canada-2              782k ± 0%       391k ± 0%  -49.95%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2        192k ± 0%       158k ± 0%  -17.81%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2            56.9k ± 0%      54.7k ± 0%   -3.84%  (p=0.008 n=5+5)
UnmarshalDataset/code-2               1.06M ± 0%      1.05M ± 0%   -1.14%  (p=0.008 n=5+5)
UnmarshalDataset/example-2            1.36k ± 0%      1.28k ± 0%   -6.15%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2      7.00 ± 0%       8.00 ± 0%  +14.29%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2         12.0 ± 0%       13.0 ± 0%   +8.33%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2        182 ± 0%        123 ± 0%  -32.42%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2           649 ± 0%        590 ± 0%   -9.09%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2             143 ± 0%        130 ± 0%   -9.09%  (p=0.008 n=5+5)

@pelletier pelletier changed the title Unmarshal specialization Unmarshal slices specialization Nov 11, 2021
@pelletier pelletier changed the title Unmarshal slices specialization Decode: slices specialization Nov 11, 2021
@pelletier pelletier added the performance Issue related to a performance problem or pull request improving performance. label Nov 11, 2021
```
name                               old time/op    new time/op    delta
UnmarshalDataset/config-2            24.9ms ± 1%    24.9ms ± 0%     ~     (p=0.413 n=5+4)
UnmarshalDataset/canada-2            66.1ms ± 0%    61.7ms ± 1%   -6.63%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2      25.3ms ± 5%    24.7ms ± 1%   -2.09%  (p=0.032 n=5+5)
UnmarshalDataset/twitter-2           10.9ms ± 2%    10.9ms ± 2%     ~     (p=1.000 n=5+5)
UnmarshalDataset/code-2               108ms ± 0%     108ms ± 0%     ~     (p=0.095 n=5+5)
UnmarshalDataset/example-2            177µs ± 2%     176µs ± 0%     ~     (p=0.841 n=5+5)
Unmarshal/SimpleDocument/struct-2     579ns ± 0%     586ns ± 1%   +1.30%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2        875ns ± 1%     876ns ± 0%     ~     (p=0.548 n=5+5)
Unmarshal/ReferenceFile/struct-2     49.7µs ± 1%    49.5µs ± 0%     ~     (p=0.095 n=5+5)
Unmarshal/ReferenceFile/map-2        80.4µs ± 0%    79.6µs ± 0%   -0.99%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2          13.9µs ± 0%    13.7µs ± 0%   -1.70%  (p=0.008 n=5+5)

name                               old speed      new speed      delta
UnmarshalDataset/config-2          42.1MB/s ± 1%  42.2MB/s ± 0%     ~     (p=0.381 n=5+4)
UnmarshalDataset/canada-2          33.3MB/s ± 0%  35.7MB/s ± 1%   +7.11%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2    22.1MB/s ± 5%  22.6MB/s ± 1%   +2.08%  (p=0.032 n=5+5)
UnmarshalDataset/twitter-2         40.7MB/s ± 2%  40.6MB/s ± 2%     ~     (p=1.000 n=5+5)
UnmarshalDataset/code-2            24.8MB/s ± 0%  24.9MB/s ± 0%     ~     (p=0.103 n=5+5)
UnmarshalDataset/example-2         45.8MB/s ± 2%  46.0MB/s ± 0%     ~     (p=0.841 n=5+5)
Unmarshal/SimpleDocument/struct-2  19.0MB/s ± 0%  18.8MB/s ± 1%   -1.26%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2     12.6MB/s ± 1%  12.6MB/s ± 0%     ~     (p=0.508 n=5+5)
Unmarshal/ReferenceFile/struct-2    105MB/s ± 1%   106MB/s ± 0%     ~     (p=0.095 n=5+5)
Unmarshal/ReferenceFile/map-2      65.2MB/s ± 0%  65.8MB/s ± 0%   +1.00%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2        39.3MB/s ± 0%  40.0MB/s ± 0%   +1.73%  (p=0.008 n=5+5)

name                               old alloc/op   new alloc/op   delta
UnmarshalDataset/config-2            5.85MB ± 0%    5.85MB ± 0%   -0.00%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2            76.6MB ± 0%    75.2MB ± 0%   -1.76%  (p=0.016 n=4+5)
UnmarshalDataset/citm_catalog-2      35.3MB ± 0%    35.0MB ± 0%   -0.71%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2           13.5MB ± 0%    13.5MB ± 0%   -0.19%  (p=0.016 n=4+5)
UnmarshalDataset/code-2              22.3MB ± 0%    22.0MB ± 0%   -1.31%  (p=0.008 n=5+5)
UnmarshalDataset/example-2            204kB ± 0%     203kB ± 0%   -0.34%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2      709B ± 0%      709B ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-2       1.08kB ± 0%    1.08kB ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/struct-2     19.8kB ± 0%    19.7kB ± 0%   -0.24%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2        37.3kB ± 0%    37.0kB ± 0%   -0.64%  (p=0.029 n=4+4)
Unmarshal/HugoFrontMatter-2          7.26kB ± 0%    7.22kB ± 0%   -0.66%  (p=0.008 n=5+5)

name                               old allocs/op  new allocs/op  delta
UnmarshalDataset/config-2              230k ± 0%      230k ± 0%   -0.00%  (p=0.000 n=5+4)
UnmarshalDataset/canada-2              447k ± 0%      391k ± 0%  -12.53%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-2        169k ± 0%      158k ± 0%   -6.20%  (p=0.029 n=4+4)
UnmarshalDataset/twitter-2            55.8k ± 0%     54.7k ± 0%   -1.88%  (p=0.029 n=4+4)
UnmarshalDataset/code-2               1.06M ± 0%     1.05M ± 0%   -1.14%  (p=0.008 n=5+5)
UnmarshalDataset/example-2            1.31k ± 0%     1.28k ± 0%   -2.21%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2      8.00 ± 0%      8.00 ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-2         13.0 ± 0%      13.0 ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/struct-2        125 ± 0%       123 ± 0%   -1.60%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2           600 ± 0%       590 ± 0%   -1.67%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2             132 ± 0%       130 ± 0%   -1.52%  (p=0.008 n=5+5)
```
```
name                               old time/op    new time/op    delta
UnmarshalDataset/config-2            24.9ms ± 0%    24.6ms ± 0%  -1.09%  (p=0.029 n=4+4)
UnmarshalDataset/canada-2            61.7ms ± 1%    62.1ms ± 3%    ~     (p=1.000 n=5+5)
UnmarshalDataset/citm_catalog-2      24.7ms ± 1%    24.2ms ± 0%  -2.30%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2           10.9ms ± 2%    10.7ms ± 1%  -1.46%  (p=0.008 n=5+5)
UnmarshalDataset/code-2               108ms ± 0%     106ms ± 0%  -1.91%  (p=0.008 n=5+5)
UnmarshalDataset/example-2            176µs ± 0%     173µs ± 0%  -1.83%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2     586ns ± 1%     587ns ± 0%    ~     (p=0.690 n=5+5)
Unmarshal/SimpleDocument/map-2        876ns ± 0%     872ns ± 0%    ~     (p=0.095 n=5+5)
Unmarshal/ReferenceFile/struct-2     49.5µs ± 0%    49.5µs ± 0%    ~     (p=0.222 n=5+5)
Unmarshal/ReferenceFile/map-2        79.6µs ± 0%    79.1µs ± 0%  -0.62%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2          13.7µs ± 0%    13.5µs ± 0%  -0.91%  (p=0.008 n=5+5)

name                               old speed      new speed      delta
UnmarshalDataset/config-2          42.2MB/s ± 0%  42.7MB/s ± 0%  +1.10%  (p=0.029 n=4+4)
UnmarshalDataset/canada-2          35.7MB/s ± 1%  35.5MB/s ± 3%    ~     (p=1.000 n=5+5)
UnmarshalDataset/citm_catalog-2    22.6MB/s ± 1%  23.1MB/s ± 0%  +2.36%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-2         40.6MB/s ± 2%  41.2MB/s ± 1%  +1.47%  (p=0.008 n=5+5)
UnmarshalDataset/code-2            24.9MB/s ± 0%  25.4MB/s ± 0%  +1.95%  (p=0.008 n=5+5)
UnmarshalDataset/example-2         46.0MB/s ± 0%  46.9MB/s ± 0%  +1.86%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-2  18.8MB/s ± 1%  18.7MB/s ± 0%    ~     (p=0.651 n=5+5)
Unmarshal/SimpleDocument/map-2     12.6MB/s ± 0%  12.6MB/s ± 0%    ~     (p=0.087 n=5+5)
Unmarshal/ReferenceFile/struct-2    106MB/s ± 0%   106MB/s ± 0%    ~     (p=0.222 n=5+5)
Unmarshal/ReferenceFile/map-2      65.8MB/s ± 0%  66.2MB/s ± 0%  +0.63%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2        40.0MB/s ± 0%  40.3MB/s ± 0%  +0.92%  (p=0.008 n=5+5)

name                               old alloc/op   new alloc/op   delta
UnmarshalDataset/config-2            5.85MB ± 0%    5.85MB ± 0%    ~     (p=1.000 n=5+5)
UnmarshalDataset/canada-2            75.2MB ± 0%    75.2MB ± 0%    ~     (p=1.000 n=5+5)
UnmarshalDataset/citm_catalog-2      35.0MB ± 0%    35.0MB ± 0%    ~     (p=0.841 n=5+5)
UnmarshalDataset/twitter-2           13.5MB ± 0%    13.5MB ± 0%    ~     (p=0.548 n=5+5)
UnmarshalDataset/code-2              22.0MB ± 0%    22.0MB ± 0%    ~     (p=0.738 n=5+5)
UnmarshalDataset/example-2            203kB ± 0%     203kB ± 0%    ~     (p=0.714 n=5+5)
Unmarshal/SimpleDocument/struct-2      709B ± 0%      709B ± 0%    ~     (all equal)
Unmarshal/SimpleDocument/map-2       1.08kB ± 0%    1.08kB ± 0%    ~     (all equal)
Unmarshal/ReferenceFile/struct-2     19.7kB ± 0%    19.7kB ± 0%    ~     (all equal)
Unmarshal/ReferenceFile/map-2        37.0kB ± 0%    37.0kB ± 0%    ~     (p=0.333 n=4+5)
Unmarshal/HugoFrontMatter-2          7.22kB ± 0%    7.22kB ± 0%    ~     (all equal)

name                               old allocs/op  new allocs/op  delta
UnmarshalDataset/config-2              230k ± 0%      230k ± 0%    ~     (p=0.556 n=4+5)
UnmarshalDataset/canada-2              391k ± 0%      391k ± 0%    ~     (all equal)
UnmarshalDataset/citm_catalog-2        158k ± 0%      158k ± 0%    ~     (p=1.000 n=4+5)
UnmarshalDataset/twitter-2            54.7k ± 0%     54.7k ± 0%    ~     (p=1.000 n=4+5)
UnmarshalDataset/code-2               1.05M ± 0%     1.05M ± 0%    ~     (all equal)
UnmarshalDataset/example-2            1.28k ± 0%     1.28k ± 0%    ~     (all equal)
Unmarshal/SimpleDocument/struct-2      8.00 ± 0%      8.00 ± 0%    ~     (all equal)
Unmarshal/SimpleDocument/map-2         13.0 ± 0%      13.0 ± 0%    ~     (all equal)
Unmarshal/ReferenceFile/struct-2        123 ± 0%       123 ± 0%    ~     (all equal)
Unmarshal/ReferenceFile/map-2           590 ± 0%       590 ± 0%    ~     (all equal)
Unmarshal/HugoFrontMatter-2             130 ± 0%       130 ± 0%    ~     (all equal)
```
pelletier added a commit that referenced this pull request Apr 15, 2022
This is a common type. Specializing it to reduce the use of reflection
yields better performance.

Similar to #669, there is a lot
to explore there.

name                               old time/op    new time/op    delta
UnmarshalDataset/config-8            13.3ms ± 0%    12.3ms ± 0%   -7.45%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8            55.7ms ± 0%    55.2ms ± 0%   -0.88%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8      16.6ms ± 1%    16.5ms ± 1%   -0.97%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8           7.10ms ± 1%    7.01ms ± 1%   -1.28%  (p=0.016 n=5+5)
UnmarshalDataset/code-8              63.8ms ± 0%    52.0ms ± 0%  -18.45%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            121µs ± 0%     119µs ± 0%   -2.13%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8     438ns ± 1%     432ns ± 1%   -1.40%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-8        594ns ± 2%     573ns ± 1%   -3.56%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-8     34.3µs ± 1%    33.7µs ± 0%   -1.95%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-8        48.6µs ± 0%    44.2µs ± 1%   -9.22%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8          7.88µs ± 1%    7.28µs ± 1%   -7.66%  (p=0.008 n=5+5)

name                               old speed      new speed      delta
UnmarshalDataset/config-8          78.9MB/s ± 0%  85.2MB/s ± 0%   +8.05%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8          39.5MB/s ± 0%  39.9MB/s ± 0%   +0.89%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8    33.6MB/s ± 1%  33.9MB/s ± 1%   +0.98%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8         62.3MB/s ± 1%  63.1MB/s ± 1%   +1.30%  (p=0.016 n=5+5)
UnmarshalDataset/code-8            42.1MB/s ± 0%  51.6MB/s ± 0%  +22.62%  (p=0.008 n=5+5)
UnmarshalDataset/example-8         66.9MB/s ± 0%  68.3MB/s ± 0%   +2.18%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8  25.1MB/s ± 1%  25.4MB/s ± 1%   +1.43%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-8     18.5MB/s ± 2%  19.2MB/s ± 1%   +3.70%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-8    153MB/s ± 1%   156MB/s ± 0%   +1.99%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-8       108MB/s ± 0%   119MB/s ± 1%  +10.16%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8        69.3MB/s ± 1%  75.0MB/s ± 1%   +8.30%  (p=0.008 n=5+5)

name                               old alloc/op   new alloc/op   delta
UnmarshalDataset/config-8            5.86MB ± 0%    5.26MB ± 0%  -10.36%  (p=0.008 n=5+5)
UnmarshalDataset/canada-8            83.0MB ± 0%    83.0MB ± 0%   -0.00%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8      34.7MB ± 0%    34.7MB ± 0%   -0.04%  (p=0.008 n=5+5)
UnmarshalDataset/twitter-8           12.7MB ± 0%    12.7MB ± 0%     ~     (p=0.548 n=5+5)
UnmarshalDataset/code-8              22.2MB ± 0%    15.3MB ± 0%  -30.76%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            186kB ± 0%     186kB ± 0%   -0.04%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8      805B ± 0%      805B ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-8       1.13kB ± 0%    1.13kB ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/struct-8     20.9kB ± 0%    20.9kB ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/map-8        38.2kB ± 0%    36.4kB ± 0%   -4.86%  (p=0.029 n=4+4)
Unmarshal/HugoFrontMatter-8          7.44kB ± 0%    7.20kB ± 0%   -3.23%  (p=0.008 n=5+5)

name                               old allocs/op  new allocs/op  delta
UnmarshalDataset/config-8              227k ± 0%      189k ± 0%  -16.74%  (p=0.029 n=4+4)
UnmarshalDataset/canada-8              782k ± 0%      782k ± 0%   -0.00%  (p=0.008 n=5+5)
UnmarshalDataset/citm_catalog-8        192k ± 0%      191k ± 0%   -0.49%  (p=0.000 n=5+4)
UnmarshalDataset/twitter-8            56.9k ± 0%     56.9k ± 0%   -0.00%  (p=0.032 n=5+5)
UnmarshalDataset/code-8               1.05M ± 0%     0.63M ± 0%  -40.52%  (p=0.008 n=5+5)
UnmarshalDataset/example-8            1.36k ± 0%     1.36k ± 0%   -0.15%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/struct-8      9.00 ± 0%      9.00 ± 0%     ~     (all equal)
Unmarshal/SimpleDocument/map-8         13.0 ± 0%      13.0 ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/struct-8        183 ± 0%       183 ± 0%     ~     (all equal)
Unmarshal/ReferenceFile/map-8           642 ± 0%       526 ± 0%  -18.07%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-8             141 ± 0%       126 ± 0%  -10.64%  (p=0.008 n=5+5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issue related to a performance problem or pull request improving performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant