Storing concrete values into interfaces often cause allocations, which has a larger impact on performance than inlining.
Re:Go Data Structures: Interfaces
by nasretdinov on Sunday February 09, 2025 @02:48AM
(#42989196)
Yeah I was really surprised by how much of a performance difference it made when calling variadic functions that support `args ...interface{}`. Literally every since call is going to be an allocation of multiple parameters when passing structs without a pointer
Re:Go Data Structures: Interfaces
by neonsunset on Sunday February 09, 2025 @03:22AM
(#42989316)
You have to manually collect and then apply the profile though (very few teams do this). A proper solution is doing a whole program view optimization (at least like the one done by .NET's NativeAOT). But typically of Go design philosophy, a stop-gap solution was chosen instead.
Re:Go Data Structures: Interfaces
by indogwetrust on Sunday February 09, 2025 @01:54AM
(#42989000)
> Go compiler seems to have trouble with inlining
not "have trouble", a deliberate design to keep compile times fast and (emitted) code size reasonable
Generally speaking the Go compiler seems to have trouble with inlining, PGO (profile guided optimization) can help though.