VictoriaMetrics/lib/persistentqueue
Aliaksandr Valialkin f4989edd96
lib/bytesutil: split Resize() into ResizeNoCopy() and ResizeWithCopy() functions
Previously bytesutil.Resize() was copying the original byte slice contents to a newly allocated slice.
This wasted CPU cycles and memory bandwidth in some places, where the original slice contents wasn't needed
after slize resizing. Switch such places to bytesutil.ResizeNoCopy().

Rename the original bytesutil.Resize() function to bytesutil.ResizeWithCopy() for the sake of improved readability.

Additionally, allocate new slice with `make()` instead of `append()`. This guarantees that the capacity of the allocated slice
exactly matches the requested size. The `append()` could return a slice with bigger capacity as an optimization for further `append()` calls.
This could result in excess memory usage when the returned byte slice was cached (for instance, in lib/blockcache).

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2007
2022-01-25 15:24:44 +02:00
..
fastqueue.go all: add support for Prometheus staleness markers 2021-08-13 12:10:17 +03:00
fastqueue_test.go all: fix golangci-lint issues 2020-03-10 19:41:46 +02:00
fastqueue_timing_test.go all: properly handle CPU limits set on the host system/container 2020-12-08 21:07:29 +02:00
persistentqueue.go lib/bytesutil: split Resize() into ResizeNoCopy() and ResizeWithCopy() functions 2022-01-25 15:24:44 +02:00
persistentqueue_test.go lib/persistentqueue: delete corrupted persistent queue instead of throwing a fatal error 2021-04-05 19:26:11 +03:00
persistentqueue_timing_test.go lib/persistentqueue: delete corrupted persistent queue instead of throwing a fatal error 2021-04-05 19:26:11 +03:00