-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
endpoint: avoid excessive allocations during restore
The way endpoint state currently is restored from header files could potentially lead to a lot of memory allocations, partially due to the fact that the respective base64 encoded state is converted to a string after being read and then converted back to a byte slice in order to decode it. Since every conversion of a byte slice to a string allocates (due to the fact that strings are immutable in Go), this essentially doubles the memory that is used which could lead to memory allocation spikes during restore. Avoid this by reading the base64 encoded endpoint state into a byte slice directly and thus reducing the size and number of allocations. Before: EndpointSuite.BenchmarkReadEPsFromDirNames 5000 399980 ns/op 83665 B/op 743 allocs/op After: EndpointSuite.BenchmarkReadEPsFromDirNames 5000 369643 ns/op 73479 B/op 731 allocs/op Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
- Loading branch information
Showing
3 changed files
with
62 additions
and
19 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
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