-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
colserde: do not cap byte slice for the last buffer when deserializing
We recently merged a change in which we cap each of the slices for buffers which was needed to have better memory estimate. However, now we might be under-estimating the footprint if the whole `bodyBytes` has a lot of unused capacity. Consider the following example when we have 3 buffers in the serialized representation: len(bodyBytes) == 10, cap(bodyBytes) == 20 len(buffer1) == 0, len(buffer2) == 1, len(buffer3) == 9. Before the original fix, our estimate would be 20 (the capacity of the second buffer) + 19 (the capacity of the third buffer) == 39 - huge over-estimate. With the original fix but without this commit: 1 + 9 == 10 - huge under-estimate. With this commit: 1 + 19 == 20 - exactly what we want. Release note: None
- Loading branch information
1 parent
ffcd641
commit 1e7354b
Showing
2 changed files
with
18 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters