grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
23.49k stars 3.4k forks source link

feat(wal): Benchmark and improve WAL writes using Reset. #13272

Closed cyriltovena closed 3 months ago

cyriltovena commented 3 months ago

What this PR does / why we need it:

This adds a benchmark and some improvement to the write path of wal segment.

Which issue(s) this PR fixes: Fixes https://github.com/grafana/loki-private/issues/1005 https://github.com/grafana/loki-private/issues/1004

❯ benchstat before.txt after.txt                                                                                                                                 
name       old time/op    new time/op    delta
Writes-16    11.9ms ±29%     6.5ms ± 2%  -44.84%  (p=0.008 n=5+5)

name       old alloc/op   new alloc/op   delta
Writes-16    12.9MB ± 9%     0.1MB ± 1%  -98.84%  (p=0.008 n=5+5)

name       old allocs/op  new allocs/op  delta
Writes-16     2.36k ±19%     0.30k ± 0%  -87.13%  (p=0.008 n=5+5)