gin-contrib / gzip

Gin middleware to enable GZIP support.
MIT License
324 stars 83 forks source link

Can we remove this Reset? #87

Open yuanjize opened 2 weeks ago

yuanjize commented 2 weeks ago

https://github.com/gin-contrib/gzip/blob/33a5d2eb2fe2cbca4bdbb77314f2e77850ceb393/handler.go#L50

Resetuse many cpu,because it will call memclrNoHeapPointers.

I think just use Reset when we get it from pool will be better, remove Reset(io.Discard)

What do youk think?

yuanjize commented 2 weeks ago

BenchmarkGzipEncode2/GzipEncode_One_reset BenchmarkGzipEncode2/GzipEncode_One_reset-16 2425 448301 ns/op 39512 B/op 30 allocs/op BenchmarkGzipEncode2/GzipEncode_Two_reset BenchmarkGzipEncode2/GzipEncode_Two_reset-16 2053 541121 ns/op 39637 B/op 30 allocs/op