3 ms·
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 t
by iTokio 2y ago
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.
- tapirl 2y agoStoring concrete values into interfaces often cause allocations, which has a larger impact on performance than inlining.
- nasretdinov 2y agoYeah 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
- indogwetrust 2y ago> Go compiler seems to have trouble with inlining not "have trouble", a deliberate design to keep compile times fast and (emitted) code size reasonable
- the_gipsy 2y agoAh yes, whichever it is, always design.
- neonsunset 2y agoYou 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.