Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
types/basetypes: Reduce memory allocations of (ObjectValue).ToTerrafo…
…rmValue() (#791) Reference: #775 The prior implementation used the exported `AttributeTypes()` method, which in this case was unnecessarily creating a copy of the map when it was only be used for walking the existing data. At scale, such as handling 1000+ objects, this creates unnecessary pressure on the Go garbage collector. `benchstat` comparison with new benchmark test: ```text goos: darwin goarch: arm64 pkg: github.com/hashicorp/terraform-plugin-framework/types/basetypes │ original │ proposed │ │ sec/op │ sec/op vs base │ ObjectValueToTerraformValue1000-10 408.4µ ± 1% 318.4µ ± 1% -22.02% (p=0.000 n=10) │ original │ proposed │ │ B/op │ B/op vs base │ ObjectValueToTerraformValue1000-10 449.2Ki ± 0% 286.6Ki ± 0% -36.19% (p=0.000 n=10) │ original │ proposed │ │ allocs/op │ allocs/op vs base │ ObjectValueToTerraformValue1000-10 2.051k ± 0% 2.020k ± 0% -1.51% (p=0.000 n=10) ```
- Loading branch information