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

Add CborReader and CborWriter #67

Merged
merged 5 commits into from
Mar 23, 2022

Commits on Mar 18, 2022

  1. Replace scratch buffers with pools

    Adds pools for small buffers used for reading cbor headers and for larger
    buffers used when reading strings. This trades off some cpu for less pressure
    on the garbage collector. The benchmarks show a notable increase in
    cpu but allocations are amortized to near zero in many cases.
    
    Internalising the management of scratch buffers simplifies the code and
    allows removal/deprecation of duplicate implementations for several functions.
    
    Users will need to re-generate marshaling methods to benefit from the removal
    of scratch buffers from those methods.
    
    Benchstat comparison with master:
    
    name               old time/op    new time/op    delta
    Marshaling-8          564ns ± 1%    1123ns ± 3%   +99.16%  (p=0.000 n=9+10)
    Unmarshaling-8       2.75µs ± 5%    3.53µs ± 4%   +28.63%  (p=0.000 n=10+10)
    LinkScan-8            744ns ± 0%    1694ns ± 1%  +127.69%  (p=0.000 n=10+9)
    Deferred-8           1.68µs ± 1%    3.90µs ± 0%  +131.76%  (p=0.000 n=10+9)
    MapMarshaling-8       317ns ± 0%     667ns ± 2%  +110.55%  (p=0.000 n=9+10)
    MapUnmarshaling-8    2.71µs ±10%    3.33µs ± 3%   +23.26%  (p=0.000 n=10+10)
    
    name               old alloc/op   new alloc/op   delta
    Marshaling-8           160B ± 0%        0B       -100.00%  (p=0.000 n=10+10)
    Unmarshaling-8       3.44kB ± 0%    1.96kB ± 0%   -42.94%  (p=0.000 n=10+10)
    LinkScan-8             112B ± 0%        0B       -100.00%  (p=0.000 n=10+10)
    Deferred-8            88.0B ± 0%     72.0B ± 0%   -18.18%  (p=0.000 n=10+10)
    MapMarshaling-8       48.0B ± 0%      2.0B ± 0%   -95.83%  (p=0.000 n=10+10)
    MapUnmarshaling-8    2.53kB ± 0%    1.54kB ± 0%   -39.15%  (p=0.000 n=10+10)
    
    name               old allocs/op  new allocs/op  delta
    Marshaling-8           10.0 ± 0%       0.0       -100.00%  (p=0.000 n=10+10)
    Unmarshaling-8         43.0 ± 0%      21.0 ± 0%   -51.16%  (p=0.000 n=10+10)
    LinkScan-8             1.00 ± 0%      0.00       -100.00%  (p=0.000 n=10+10)
    Deferred-8             3.00 ± 0%      2.00 ± 0%   -33.33%  (p=0.000 n=10+10)
    MapMarshaling-8        5.00 ± 0%      2.00 ± 0%   -60.00%  (p=0.000 n=10+10)
    MapUnmarshaling-8      56.0 ± 0%      27.0 ± 0%   -51.79%  (p=0.000 n=10+10)
    iand committed Mar 18, 2022
    Configuration menu
    Copy the full SHA
    f71164a View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2022

  1. Add CborReader and CborWriter

    iand committed Mar 22, 2022
    Configuration menu
    Copy the full SHA
    da8b264 View commit details
    Browse the repository at this point in the history
  2. fix: specialize readByte and readByteBuf for CborReader

    This gives a small improvement in some cases, but an 8% improvement in
    map marshalling speed.
    Stebalien committed Mar 22, 2022
    Configuration menu
    Copy the full SHA
    7c034ad View commit details
    Browse the repository at this point in the history
  3. fix: remove unecessary scratch allocation

    It doesn't look like this escapes, but removing this saves ~5% for
    LinkScan, Deferred, and MapMarshaling.
    Stebalien committed Mar 22, 2022
    Configuration menu
    Copy the full SHA
    6c166f2 View commit details
    Browse the repository at this point in the history

Commits on Mar 23, 2022

  1. Use CborWriter in WriteCid

    iand committed Mar 23, 2022
    Configuration menu
    Copy the full SHA
    b835d9c View commit details
    Browse the repository at this point in the history