News for hackers. Stuff that matters.
Re:Making a Go program 70% faster with a one character change by dist1ll on Monday November 14, 2022 @04:19PM (#33601261)
> but it puts a lot more pressure on the GC than simple local stack variables.

Do you have evidence for this claim? AFAIK the Go compiler does escape analysis, and allocates pointers that don't escape on the stack.

Re:Making a Go program 70% faster with a one character change by throwaway894345 on Monday November 14, 2022 @04:43PM (#33601607)
This is true, but it's hard to tell if a pointer escapes or not without actually profiling. That said, I don't think the answer is to avoid pointers, but rather to get comfortable with profiling the escape analyzer. By default, I just stick to the subset of Go which I know won't escape--functions can take pointer parameters, but I'm very careful about returning pointers to data that would otherwise be stack-allocated (even though it's not especially idiomatic, I'll often prefer mutating an `out T` parameter rather than returning a `T` because I know the former will not allocate).