Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typedesc: avoid slice copy when hydrating enums
A profile showed that when an enum has a lot of values, hydrating it can become expensive since it requires initializing a large slice. Since these objects are immutable, we can just reference the slice directly. ``` goos: darwin goarch: arm64 │ bench-old │ bench-new │ │ sec/op │ sec/op vs base │ ResolveTypeByOID-10 106.266µ ± 4% 1.246µ ± 14% -98.83% (p=0.002 n=6) │ bench-old │ bench-new │ │ B/op │ B/op vs base │ ResolveTypeByOID-10 422992.5 ± 0% 453.0 ± 0% -99.89% (p=0.002 n=6) │ bench-old │ bench-new │ │ allocs/op │ allocs/op vs base │ ResolveTypeByOID-10 51.00 ± 4% 12.00 ± 0% -76.47% (p=0.002 n=6) ``` Release note (performance improvement): Improved the cost of resolving a user-defined enum type that has many values.
- Loading branch information