Skip to content

Conversation

@pafuent
Copy link
Contributor

@pafuent pafuent commented Nov 7, 2020

Adding a sync.Pool for the *gzip.Writer reduces the allocations of the Compress middleware in 50% and gives an increase on execution speed of a 85%
This fix #1643

Here are the Benchmarks

Current version

PASS ok github.com/labstack/echo/v4 0.004s goos: linux goarch: amd64 pkg: github.com/labstack/echo/v4/middleware BenchmarkGzip-2 7473 151518 ns/op 815268 B/op 33 allocs/op PASS ok github.com/labstack/echo/v4/middleware 1.901s 

Using a sync.Pool

PASS ok github.com/labstack/echo/v4 0.005s goos: linux goarch: amd64 pkg: github.com/labstack/echo/v4/middleware BenchmarkGzip-2 47617 23736 ns/op 1430 B/op 16 allocs/op PASS ok github.com/labstack/echo/v4/middleware 1.395s 
Adding a sync.Pool for the *gzip.Writer reduces the allocations of the Compress middleware in 50% and gives an increase on execution speed of a 85% This fix labstack#1643
@codecov
Copy link

codecov bot commented Nov 7, 2020

Codecov Report

Merging #1672 (ac54e13) into master (ceffc10) will increase coverage by 0.29%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@ ## master #1672 +/- ## ========================================== + Coverage 84.06% 84.35% +0.29%  ========================================== Files 28 28 Lines 1901 1911 +10 ========================================== + Hits 1598 1612 +14  + Misses 191 189 -2  + Partials 112 110 -2 
Impacted Files Coverage Δ
middleware/compress.go 84.31% <100.00%> (+13.58%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ceffc10...ac54e13. Read the comment docs.

@imxyb
Copy link
Contributor

imxyb commented Nov 9, 2020

Very correct, this is exactly what I think

@lammel lammel merged commit 2ab69d8 into labstack:master Nov 10, 2020
@lammel
Copy link
Contributor

lammel commented Nov 10, 2020

Impressive! Very clean patch, thanks @pafuent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants