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

zstd: Improve memory usage on small streaming encodes #1007

Merged
merged 2 commits into from
Sep 18, 2024

Commits on Sep 18, 2024

  1. zstd: Improve memory usage on small streaming encodes

    Very small streams will use EncodeAll internally when closing and no header has been written.
    
    This will pull a new encoder from the async buffer.
    
    Instead re-use the stream encoder.
    
    Before:
    ```
    BenchmarkMem/flush-32         	    1359	    837989 ns/op	 7376959 B/op	     109 allocs/op
    BenchmarkMem/no-flush-32      	     129	   8884753 ns/op	112044489 B/op	     254 allocs/op
    ```
    
    After:
    ```
    BenchmarkMem/flush-32         	    1254	    922593 ns/op	 7376966 B/op	     109 allocs/op
    BenchmarkMem/no-flush-32      	    1488	    841270 ns/op	 7374164 B/op	      29 allocs/op
    ```
    
    Test is pretty much worst case, but shows the issue nicely.
    klauspost committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    c3e680a View commit details
    Browse the repository at this point in the history
  2. Go mod fun

    klauspost committed Sep 18, 2024
    Configuration menu
    Copy the full SHA
    a8f18e0 View commit details
    Browse the repository at this point in the history