6 ms·
> that the actual performance cost for checking the error return is random, variable, and small. Good to know :) That is certainly not the article's conclusion
by knz42 6y ago
> that the actual performance cost for checking the error return is random, variable, and small. Good to know :)
That is certainly not the article's conclusion. The cost is deterministic, constant and non-negligible.
- Bootvis 6y agoAre you the author? I ask because the domain is similar to your username.
- Rochus 6y ago> and non-negligible This is probably a matter of discretion. Considering the overall performance of Go applications compared to other languages, 4 to 10% is quite low. The measurement error might also be a few percent.
- marcus_holmes 6y ago> Previously, in Go 1.10, this fixed cost was non-negligible, climbing upwards of dozens of nanoseconds. Thanks to recent improvements in the Go compiler however, as well as general improvements in CPU micro-architectures, this cost has been greatly reduced in 2020. I read that as "used to be non-negligable, is now negligable" 4%-10% depending on compiler and architecture is pretty variable, to my way of thinking. YMMV. also kinda random, in that there's nothing I can do in the code to determine how much overhead it costs, or change that (apart from ignoring Go's convention on error handling completely, which I'm not going to do because it wasn't a convention for performance reasons in the first place).
- knz42 6y agoYou're mis-reading the text. The reduction in cost pertains to the try/catch (defer/recover) mechanism, not error returns. The cost of error returns has not reduced since Go 1.10.
- marcus_holmes 6y agoAh ok, thanks for correcting my mis-apprehension :)