haha, golang compress/gzip wat? Results in Magical level 6 compression I guess
package main
import (
"bytes"
"compress/gzip"
"fmt"
)
func main() {
data := bytes.Repeat([]byte{0x00}, 64<<18+1)
for lvl := -2; lvl <= 9; lvl++ {
var b bytes.Buffer
w, err := gzip.NewWriterLevel(&b, lvl)
if err != nil {
continue
}
w.Write(data)
w.Close()
fmt.Printf("level %2d: %d bytes\n", lvl, b.Len())
}
}level -2: 2097189 bytes
level -1: 32884 bytes
level 0: 16778522 bytes
level 1: 16628 bytes
level 2: 16628 bytes
level 3: 16627 bytes
level 4: 16627 bytes
level 5: 16627 bytes
level 6: 32884 bytes
level 7: 16304 bytes
level 8: 16304 bytes
level 9: 16304 bytes
lp0_on_fire@cupoftea..
replied 12 Sep 2026 15:05 +0000
in reply to: https://benjojo.co.uk/u/benjojo/h/rm527z4t1cTl4J333T
@benjojo, testing locally-available versions, I see that 1.24.4 and 1.26.8 both return sane results, but 1.27.4 shows that odd result at levels -1 and 6.
benjojo
replied 12 Sep 2026 15:11 +0000
in reply to: https://cupoftea.social/ap/users/117147216143373345/statuses/117258683467735212
@lp0_on_fire They did rewrite a lot of the compressor in 1.27 so I think this is a hangover from that https://github.com/golang/go/commit/388145c51b0781594327b2646894dfaaaaaac0c6 I dunno if it only produces weird results on this synthetic benchmark, I only went looking because it tripped over one of my unit tests
ryanc@infosec.exchan..
replied 12 Sep 2026 14:17 +0000
in reply to: https://benjojo.co.uk/u/benjojo/h/rm527z4t1cTl4J333T
lobocode@hachyderm.i..
replied 12 Sep 2026 14:20 +0000
in reply to: https://benjojo.co.uk/u/benjojo/h/rm527z4t1cTl4J333T
Arpie4Math@mathstodo..
replied 12 Sep 2026 14:45 +0000
in reply to: https://hachyderm.io/users/lobocode/statuses/117258509019354939
jernej__s@infosec.ex..
replied 12 Sep 2026 15:25 +0000
in reply to: https://hachyderm.io/users/lobocode/statuses/117258509019354939
MaddieM4@raphus.soci..
replied 12 Sep 2026 14:26 +0000
in reply to: https://benjojo.co.uk/u/benjojo/h/rm527z4t1cTl4J333T
dysfun@social.treeho..
replied 12 Sep 2026 14:33 +0000
in reply to: https://benjojo.co.uk/u/benjojo/h/rm527z4t1cTl4J333T