News for hackers. Stuff that matters.
Re:More powerful Go execution traces by icholy on Friday March 15, 2024 @10:23AM (#39716093)
Creating stack traces is expensive.
Re:More powerful Go execution traces by tbarbugli on Friday March 15, 2024 @01:28PM (#39718323)
you only do it when there is a not nil err + being able to have a stacktrace is worth more than whatever it costs is CPU
Re:More powerful Go execution traces by kbolino on Saturday March 16, 2024 @10:44AM (#39726389)
Good error-wrapping discipline works better than stack traces, because not only do you have a trace of the calling context, you also have the values that caused the problem. Granted, a stack trace "always works", but it will never have the values of important variables.
Re:More powerful Go execution traces by derekperkins on Saturday March 16, 2024 @04:52PM (#39729389)
We do both and it works great
Re:More powerful Go execution traces by Cthulhu_ on Monday March 18, 2024 @06:23AM (#39742148)
Now you mention it, a stack trace with function calls and all their arguments would be really powerful. But also expensive, ideally it would have zero overhead or only have the cost if you actually look at it / want to debug it.
Re:More powerful Go execution traces by kbolino on Monday March 18, 2024 @05:12PM (#39750087)
One of the major optimizations is to pass function arguments in registers instead of on the stack. These registers might preserve their original values by the time you unwind the stack, but in many cases, probably won't. Preserving those values would lead to fewer available registers and/or more frequent register saving, which would create at least some overhead, even if you don't ever inspect it.

There are probably lots of situations where it's worth it, though.

Re:More powerful Go execution traces by Cthulhu_ on Monday March 18, 2024 @06:22AM (#39742144)
That's still under the assumption that errors are exceptional, rare, and require a stacktrace to debug. But most errors are not exceptional and do not need debugging, like idk, a row not found error in a database.

A crash, sure, that might need a stacktrace to debug. But that's already in place.