feat: Avoid boxing primitives in Go in sequence concatenations as well #6361
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was changed?
Continuing from #6353, this change ensures the same optimization to avoid boxing bytes, Chars and CodePoints in sequences is also used in the concatenation optimization implemented in
dafnyRuntime.dfy. In particular, it ensures the newArrays created to hold the result are also optimized for those types. This required modifying theSequence<T>implementation to expose aPrototypeArray()to indicate the array type at runtime. The overall solution mirrors the solution inDafnyRuntimeJavaquite closely.How has this been tested?
Existing tests. Performance improvement was measured using https://github.com/aws/aws-encryption-sdk/tree/mainline/esdk-performance-testing/benchmarks/go. On a payload of 100 MB, the peak memory usage before was 5822 MB, and after the optimization was 595 MB. The average latency also improved from 3652 ms to 2047 ms.
By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.