Hacker News new | ask | show | jobs
by knz42 1976 days 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.

3 comments

> 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).

You'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.

Ah ok, thanks for correcting my mis-apprehension :)
> 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.

Are you the author? I ask because the domain is similar to your username.