News for hackers. Stuff that matters.
Re:Go Data Structures: Interfaces by iTokio on Sunday February 09, 2025 @01:47AM (#42988969)
If you are mindful of performance, one thing to be careful of, is that interfaces often prevent inlining and can cause performance issues.

Generally speaking the Go compiler seems to have trouble with inlining, PGO (profile guided optimization) can help though.

Re:Go Data Structures: Interfaces by tapirl on Sunday February 09, 2025 @01:56AM (#42989007)
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

Re:Go Data Structures: Interfaces by the_gipsy on Sunday February 09, 2025 @03:11AM (#42989280)
Ah yes, whichever it is, always design.