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

Reduce allocations in flate decompressor and minor code improvements #869

Merged
merged 11 commits into from
Oct 10, 2023

Commits on Oct 8, 2023

  1. made f.step an enum instead of func pointer

    according to my local benchmarks, it doesn't affect throughtput anyhow, but leaves constant 1 allocation/op in decompressor benchmarks
    flrdv committed Oct 8, 2023
    Configuration menu
    Copy the full SHA
    6a1c1c6 View commit details
    Browse the repository at this point in the history
  2. removed useless array-to-slice conversion

    this conversion doesn't do anything, and removing it doesn't fail any of the tests
    flrdv committed Oct 8, 2023
    Configuration menu
    Copy the full SHA
    1203209 View commit details
    Browse the repository at this point in the history
  3. made benchmarks more accurate by removing io.Copy call

    as io.Copy is just an alias for io.CopyBuffer, but passing nil instead of the actual buffer, it is being allocated internally. So better to pass it manually
    flrdv committed Oct 8, 2023
    Configuration menu
    Copy the full SHA
    a4773a9 View commit details
    Browse the repository at this point in the history
  4. removed useless operation of nulling the length of the slice

    this operation does nothing, so remoed it
    flrdv committed Oct 8, 2023
    Configuration menu
    Copy the full SHA
    c127997 View commit details
    Browse the repository at this point in the history
  5. moved b.StartTimer() to the bottom

    previous variant wasn't actually adding a big misaccuracy, but better to place it anyway just before a benchmarking code
    flrdv committed Oct 8, 2023
    Configuration menu
    Copy the full SHA
    98e21c7 View commit details
    Browse the repository at this point in the history
  6. replaced indirect decoder call with direct

    instead of returning func ptr, calling the method directly. This also doesn't bring a lot of performance gains, but on microbenchmarks may be visible
    flrdv committed Oct 8, 2023
    Configuration menu
    Copy the full SHA
    4c8d7a2 View commit details
    Browse the repository at this point in the history

Commits on Oct 9, 2023

  1. removed somehow commented code

    flrdv committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    e40efbf View commit details
    Browse the repository at this point in the history
  2. moved execution of next step into the dedicated method

    this improves readability of the code. Also added a debug print in case next step enumeric is unrecognized. However, everything will silently fail even without this print
    flrdv committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    d517f8e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    fbb9795 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    863cd97 View commit details
    Browse the repository at this point in the history
  5. rollback to io.Copy

    as flate reader implements WriterTo interface, there's completely no difference what to use
    flrdv committed Oct 9, 2023
    Configuration menu
    Copy the full SHA
    1248009 View commit details
    Browse the repository at this point in the history