From e2586bc67443518703b4609b02899f0ee4bcb1cb Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Mon, 1 Apr 2024 18:12:09 -0700 Subject: [PATCH] logtail: always zstd compress with FastestCompression and LowMemory (#11583) This is based on empirical testing using actual logs data. FastestCompression only incurs a marginal <1% compression ratio hit for a 2.25x reduction in memory use for small payloads (which are common if log uploads happen at a decently high frequency). The memory savings for large payloads is much lower (less than 1.1x reduction). LowMemory only incurs a marginal <5% hit on performance for a 1.6-2.0x reduction in memory use for small or large payloads. The memory gains for both settings justifies the loss of benefits, which are arguably minimal. tailscale/corp#18514 Signed-off-by: Joe Tsai --- logtail/logtail.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/logtail/logtail.go b/logtail/logtail.go index a1a6c196e..ecc3a1c91 100644 --- a/logtail/logtail.go +++ b/logtail/logtail.go @@ -384,11 +384,9 @@ func (l *Logger) uploading(ctx context.Context) { switch { case l.zstdEncoder != nil: zbody = l.zstdEncoder.EncodeAll(body, nil) - case l.lowMem: + default: zbody = zstdframe.AppendEncode(nil, body, zstdframe.FastestCompression, zstdframe.LowMemory(true)) - default: - zbody = zstdframe.AppendEncode(nil, body) } // Only send it compressed if the bandwidth savings are sufficient.