logoalt Hacker News

lou1306yesterday at 11:44 AM1 replyview on HN

Better at Go for automated reasoning tools, this means quite a lot of array lookups within tight loops. I asked because I noticed some AI agents quickly want to jump on the "eliminate all bounds checks" wagon as soon as the low-hanging optimization fruits have been picked, and it takes some hard data to put some sense into them. My question really was: is this kind of preliminary profiling enough, are there other pitfalls of arrays/slices in Go I am missing, etc.

> probably you do not need to do any of that.

Indeed, I find that at least in my case, on a pretty average Intel machine these checks add very little overhead, especially compared to the benefits. I do not really understand how the examples in the blog post can get 100% (1st one) or even 10% (2nd one) faster.

(And yeah, I know that the obvious solution is to develop these tools in C/C++: I am just exploring the capabilities of Go in that space).


Replies

ahk-devyesterday at 12:32 PM

My guess is the 100% case is one of those situations where the benchmark is almost entirely measuring the tiny function itself. If half the instructions are bounds checks and branches, removing them can easily double throughput in a microbenchmark. I'd be curious what happens once that function is part of a larger pipeline where memory access or other work dominates.