Skip to content

Add vfs deflate reader pool

Arran Walker requested to merge ajwalker/deflate-pool into master

Adds a deflate reader pool and some simple benchmarks.

Go uses a similar pool by default when using zip.File.Open(). Due to handling this manually, this doesn't get used.

This MR further improve matters by also pooling the bufio.Reader for buffer re-use. Without this, internally, flate.NewReader will create a new one (even with Reset()).

Before

goos: darwin
goarch: amd64
pkg: gitlab.com/gitlab-org/gitlab-pages/internal/vfs/zip
BenchmarkArchiveRead32k-16    	    5808	    898132 ns/op	  117288 B/op	     785 allocs/op
BenchmarkArchiveRead64k-16    	    8790	    648066 ns/op	  113077 B/op	     782 allocs/op
BenchmarkArchiveRead1m-16     	    5667	   1046275 ns/op	  108712 B/op	     780 allocs/op

After

goos: darwin
goarch: amd64
pkg: gitlab.com/gitlab-org/gitlab-pages/internal/vfs/zip
BenchmarkArchiveRead32k-16    	   12067	    490490 ns/op	   66391 B/op	     774 allocs/op
BenchmarkArchiveRead64k-16    	   12158	    486503 ns/op	   63553 B/op	     773 allocs/op
BenchmarkArchiveRead1m-16     	    7038	    828166 ns/op	   62406 B/op	     772 allocs/op

Extra benchmarks !413 (comment 482616673)

Edited by Jaime Martinez

Merge request reports