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: code cleanup for struct cache #659

Merged
merged 6 commits into from Nov 7, 2021
Merged

Decode: code cleanup for struct cache #659

merged 6 commits into from Nov 7, 2021

Conversation

pelletier
Copy link
Owner

Tiny bit of clean up for the struct fields cache. Also avoid re-creating reflect.Type objects in maps when possible.

name                               old time/op    new time/op    delta
UnmarshalDataset/config-2            24.9ms ± 0%    24.5ms ± 0%  -1.52%  (p=0.016 n=4+5)
UnmarshalDataset/canada-2            85.9ms ± 2%    85.6ms ± 1%    ~     (p=1.000 n=5+5)
UnmarshalDataset/citm_catalog-2      26.0ms ± 4%    25.8ms ± 1%    ~     (p=1.000 n=5+5)
UnmarshalDataset/twitter-2           9.41ms ± 2%    9.28ms ± 0%  -1.33%  (p=0.008 n=5+5)
UnmarshalDataset/code-2               107ms ± 1%     106ms ± 1%    ~     (p=0.095 n=5+5)
UnmarshalDataset/example-2            164µs ± 3%     163µs ± 2%    ~     (p=0.690 n=5+5)
Unmarshal/SimpleDocument/struct-2     567ns ± 3%     531ns ± 0%  -6.39%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2        855ns ± 1%     835ns ± 1%  -2.30%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2     54.7µs ± 1%    53.3µs ± 0%  -2.64%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2        84.7µs ± 1%    82.4µs ± 0%  -2.82%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2          14.3µs ± 0%    14.3µs ± 0%    ~     (p=0.222 n=5+5)

name                               old speed      new speed      delta
UnmarshalDataset/config-2          42.2MB/s ± 0%  42.8MB/s ± 0%  +1.54%  (p=0.016 n=4+5)
UnmarshalDataset/canada-2          25.6MB/s ± 2%  25.7MB/s ± 1%    ~     (p=1.000 n=5+5)
UnmarshalDataset/citm_catalog-2    21.5MB/s ± 4%  21.7MB/s ± 1%    ~     (p=0.897 n=5+5)
UnmarshalDataset/twitter-2         47.0MB/s ± 2%  47.6MB/s ± 0%  +1.35%  (p=0.008 n=5+5)
UnmarshalDataset/code-2            25.1MB/s ± 1%  25.3MB/s ± 1%    ~     (p=0.095 n=5+5)
UnmarshalDataset/example-2         49.4MB/s ± 3%  49.6MB/s ± 2%    ~     (p=0.690 n=5+5)
Unmarshal/SimpleDocument/struct-2  19.4MB/s ± 3%  20.7MB/s ± 0%  +6.77%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2     12.9MB/s ± 1%  13.2MB/s ± 1%  +2.36%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2   95.8MB/s ± 1%  98.4MB/s ± 0%  +2.71%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/map-2      61.9MB/s ± 1%  63.6MB/s ± 0%  +2.89%  (p=0.008 n=5+5)
Unmarshal/HugoFrontMatter-2        38.1MB/s ± 0%  38.1MB/s ± 0%    ~     (p=0.206 n=5+5)

```
name                               old time/op    new time/op    delta
UnmarshalDataset/config-2            24.9ms ± 0%    24.7ms ± 0%  -0.76%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2            85.5ms ± 1%    85.1ms ± 1%    ~     (p=0.286 n=4+5)
UnmarshalDataset/citm_catalog-2      26.2ms ± 2%    25.9ms ± 1%    ~     (p=0.222 n=5+5)
UnmarshalDataset/twitter-2           9.41ms ± 1%    9.31ms ± 0%  -1.10%  (p=0.008 n=5+5)
UnmarshalDataset/code-2               107ms ± 0%     106ms ± 1%  -0.88%  (p=0.032 n=5+5)
UnmarshalDataset/example-2            164µs ± 1%     162µs ± 1%    ~     (p=0.056 n=5+5)
Unmarshal/SimpleDocument/struct-2     556ns ± 1%     549ns ± 0%  -1.33%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2        847ns ± 0%     835ns ± 1%  -1.40%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2     54.5µs ± 0%    54.6µs ± 0%    ~     (p=0.556 n=5+4)
Unmarshal/ReferenceFile/map-2        82.6µs ± 0%    82.6µs ± 0%    ~     (p=0.730 n=4+5)
Unmarshal/HugoFrontMatter-2          14.4µs ± 0%    14.3µs ± 0%  -0.61%  (p=0.008 n=5+5)

name                               old speed      new speed      delta
UnmarshalDataset/config-2          42.2MB/s ± 0%  42.5MB/s ± 0%  +0.76%  (p=0.008 n=5+5)
UnmarshalDataset/canada-2          25.7MB/s ± 1%  25.9MB/s ± 1%    ~     (p=0.286 n=4+5)
UnmarshalDataset/citm_catalog-2    21.3MB/s ± 2%  21.6MB/s ± 1%    ~     (p=0.246 n=5+5)
UnmarshalDataset/twitter-2         46.9MB/s ± 1%  47.5MB/s ± 0%  +1.12%  (p=0.008 n=5+5)
UnmarshalDataset/code-2            25.0MB/s ± 0%  25.2MB/s ± 1%  +0.89%  (p=0.032 n=5+5)
UnmarshalDataset/example-2         49.5MB/s ± 1%  49.9MB/s ± 1%    ~     (p=0.056 n=5+5)
Unmarshal/SimpleDocument/struct-2  19.8MB/s ± 1%  20.0MB/s ± 0%  +1.36%  (p=0.008 n=5+5)
Unmarshal/SimpleDocument/map-2     13.0MB/s ± 0%  13.2MB/s ± 1%  +1.42%  (p=0.008 n=5+5)
Unmarshal/ReferenceFile/struct-2   96.1MB/s ± 0%  96.0MB/s ± 0%    ~     (p=0.556 n=5+4)
Unmarshal/ReferenceFile/map-2      63.4MB/s ± 0%  63.4MB/s ± 0%    ~     (p=0.794 n=4+5)
Unmarshal/HugoFrontMatter-2        37.9MB/s ± 0%  38.1MB/s ± 0%  +0.61%  (p=0.008 n=5+5)
```
Idea from segmentio/encoding/json.
@pelletier pelletier added the performance Issue related to a performance problem or pull request improving performance. label Nov 7, 2021
@pelletier pelletier merged commit dc1740d into v2 Nov 7, 2021
@pelletier pelletier deleted the cleanup-struct-cache branch November 7, 2021 23:35
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