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

Optimise zlib reader and consolidate sync.Pools #608

Merged
merged 4 commits into from Nov 7, 2022

Commits on Nov 7, 2022

  1. Use Sync.Pool pointers to optimise memory usage

    Signed-off-by: Paulo Gomes <pjbgf@linux.com>
    pjbgf committed Nov 7, 2022
    Copy the full SHA
    123cdde View commit details
    Browse the repository at this point in the history
  2. Optimise Reference.String()

    Decreases allocations and bytes per operation by using string builder
    with a predefined size.
    
    One additional allocation has been removed by using its own implementation
    of Strings(). The reason behind this was due to the fact the calls to
    .String() are more recurrent than .Strings() and the performance impact
    was worth the code duplication.
    
    Benchmark results:
    cpu: 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    name                        old time/op    new time/op    delta
    ReferenceStringSymbolic-16     140ns ± 4%      40ns ± 9%  -71.19%  (p=0.008 n=5+5)
    ReferenceStringHash-16         174ns ±14%      85ns ± 4%  -51.13%  (p=0.008 n=5+5)
    ReferenceStringInvalid-16     48.9ns ± 2%     1.5ns ± 3%  -96.96%  (p=0.008 n=5+5)
    
    name                        old alloc/op   new alloc/op   delta
    ReferenceStringSymbolic-16     88.0B ± 0%     32.0B ± 0%  -63.64%  (p=0.008 n=5+5)
    ReferenceStringHash-16          176B ± 0%      144B ± 0%  -18.18%  (p=0.008 n=5+5)
    ReferenceStringInvalid-16      0.00B          0.00B          ~     (all equal)
    
    name                        old allocs/op  new allocs/op  delta
    ReferenceStringSymbolic-16      4.00 ± 0%      1.00 ± 0%  -75.00%  (p=0.008 n=5+5)
    ReferenceStringHash-16          5.00 ± 0%      3.00 ± 0%  -40.00%  (p=0.008 n=5+5)
    ReferenceStringInvalid-16       0.00           0.00          ~     (all equal)
    
    Signed-off-by: Paulo Gomes <pjbgf@linux.com>
    pjbgf committed Nov 7, 2022
    Copy the full SHA
    ffa7e69 View commit details
    Browse the repository at this point in the history
  3. Optimize zlib reader and consolidate sync.pools

    Expands on the optimisations from fluxcd#5
    and ensures that zlib reader does not need to recreate a deflate
    dictionary at every use.
    
    The use of sync pools was consolidated into a new sync utils package.
    
    name       old time/op    new time/op    delta
    Parser-16    7.51ms ± 3%    7.71ms ± 6%     ~     (p=0.222 n=5+5)
    
    name       old alloc/op   new alloc/op   delta
    Parser-16    4.65MB ± 3%    1.90MB ± 3%  -59.06%  (p=0.008 n=5+5)
    
    name       old allocs/op  new allocs/op  delta
    Parser-16     3.48k ± 0%     3.32k ± 0%   -4.57%  (p=0.016 n=5+4)
    
    Signed-off-by: Paulo Gomes <pjbgf@linux.com>
    pjbgf committed Nov 7, 2022
    Copy the full SHA
    9490da0 View commit details
    Browse the repository at this point in the history
  4. tests: Replace time.sleep with eventually

    The previous approach was intermittently flake, leading to different
    results based on external results.
    
    The check for goroutines numbers now checks for less or equal, as the
    goal of the assertion is to confirm no goroutine is being leaked.
    
    Signed-off-by: Paulo Gomes <pjbgf@linux.com>
    pjbgf committed Nov 7, 2022
    Copy the full SHA
    a2c309d View commit details
    Browse the repository at this point in the history