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

optimize byte reading #35

Merged
merged 1 commit into from
Aug 10, 2020
Merged

Conversation

Stebalien
Copy link
Collaborator

When using cbor-gen, we usually work with byte buffers/readers. Calling ReadByte on a byte.Reader/byte.Buffer is much faster than calling Read and copying into a slice.

name            old time/op    new time/op    delta
Marshaling-4       911ns ± 2%     904ns ± 5%     ~     (p=0.646 n=9+10)
Unmarshaling-4    4.46µs ± 1%    3.94µs ± 2%  -11.55%  (p=0.000 n=10+8)
LinkScan-4        4.65µs ± 2%    4.01µs ± 2%  -13.76%  (p=0.000 n=9+10)
Deferred-4        3.68µs ± 3%    3.02µs ± 4%  -17.91%  (p=0.000 n=10+10)

name            old alloc/op   new alloc/op   delta
Marshaling-4        160B ± 0%      160B ± 0%     ~     (all equal)
Unmarshaling-4    3.46kB ± 0%    3.46kB ± 0%     ~     (all equal)
LinkScan-4          880B ± 0%      880B ± 0%     ~     (p=0.650 n=10+10)
Deferred-4         96.0B ± 0%     96.0B ± 0%     ~     (all equal)

name            old allocs/op  new allocs/op  delta
Marshaling-4        10.0 ± 0%      10.0 ± 0%     ~     (all equal)
Unmarshaling-4      43.0 ± 0%      43.0 ± 0%     ~     (all equal)
LinkScan-4          25.0 ± 0%      25.0 ± 0%     ~     (all equal)
Deferred-4          3.00 ± 0%      3.00 ± 0%     ~     (all equal)

When using cbor-gen, we _usually_ work with byte buffers/readers. Calling
`ReadByte` on a byte.Reader/byte.Buffer is much faster than calling `Read` and
copying into a slice.

    name            old time/op    new time/op    delta
    Marshaling-4       911ns ± 2%     904ns ± 5%     ~     (p=0.646 n=9+10)
    Unmarshaling-4    4.46µs ± 1%    3.94µs ± 2%  -11.55%  (p=0.000 n=10+8)
    LinkScan-4        4.65µs ± 2%    4.01µs ± 2%  -13.76%  (p=0.000 n=9+10)
    Deferred-4        3.68µs ± 3%    3.02µs ± 4%  -17.91%  (p=0.000 n=10+10)

    name            old alloc/op   new alloc/op   delta
    Marshaling-4        160B ± 0%      160B ± 0%     ~     (all equal)
    Unmarshaling-4    3.46kB ± 0%    3.46kB ± 0%     ~     (all equal)
    LinkScan-4          880B ± 0%      880B ± 0%     ~     (p=0.650 n=10+10)
    Deferred-4         96.0B ± 0%     96.0B ± 0%     ~     (all equal)

    name            old allocs/op  new allocs/op  delta
    Marshaling-4        10.0 ± 0%      10.0 ± 0%     ~     (all equal)
    Unmarshaling-4      43.0 ± 0%      43.0 ± 0%     ~     (all equal)
    LinkScan-4          25.0 ± 0%      25.0 ± 0%     ~     (all equal)
    Deferred-4          3.00 ± 0%      3.00 ± 0%     ~     (all equal)
@whyrusleeping whyrusleeping merged commit 211df3b into whyrusleeping:master Aug 10, 2020
@aschmahmann aschmahmann mentioned this pull request May 14, 2021
71 tasks
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.

2 participants