Skip to content

Commit

Permalink
Removing the pre-allocation of a buffer when serializing blocks, in m…
Browse files Browse the repository at this point in the history
…ost of my empirical testing we were using 9-10k out of the 32k allocated leaving about 2/3 of the buffer allocated and unused times the number of blocks per chunk, times the number of chunks kept in memory. This was adding up to a fair amount of allocated but unused space.
  • Loading branch information
slim-bean authored and Ed committed Jun 17, 2019
1 parent 3b24a25 commit c3084db
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/chunkenc/gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (hb *headBlock) append(ts int64, line string) error {
}

func (hb *headBlock) serialise(cw func(w io.Writer) CompressionWriter) ([]byte, error) {
buf := bytes.NewBuffer(make([]byte, 0, 1<<15)) // 32K. Pool it later.
buf := &bytes.Buffer{}
encBuf := make([]byte, binary.MaxVarintLen64)
compressedWriter := cw(buf)
for _, logEntry := range hb.entries {
Expand Down

0 comments on commit c3084db

Please sign in to comment.