Print(“lol”) doubled the speed of my Go function
1–10 of 130 posts
Re: Print(“lol”) doubled the speed of my Go function
#2Edit to add: does removing it make any difference?
Re: Print(“lol”) doubled the speed of my Go function
#3Why is there a "continue" at all in the first code sample? Edit to add: does removing it make any difference?
It is there only to match the continue in the second code sample, where it is needed.
Re: Print(“lol”) doubled the speed of my Go function
#4If you are interested in this sort of thing, check out comp.arch!
Re: Print(“lol”) doubled the speed of my Go function
#5Why is there a "continue" at all in the first code sample? Edit to add: does removing it make any difference?
Good question. As you can see in the comment in the github repo, it has no effect. https://github.com/ludi317/max/blob/master/blog/max_test.go#... It is there only to match the continue in the second code sample, where it is needed.
I'm curious if the performance difference noted in the article happens on Intel/AMD as well...
Re: Print(“lol”) doubled the speed of my Go function
#6Update: It seems to be the conditional move, see https://news.ycombinator.com/item?id=37245325
Re: Print(“lol”) doubled the speed of my Go function
#7Unfortunately, the issue here is that the performance depends on the input and so such hints wouldn't help (unless you knew a-priori you were dealing with mostly-sorted data). Presumably the min-max (and lol) versions perform worse for descending arrays?
Re: Print(“lol”) doubled the speed of my Go function
#8Re: Print(“lol”) doubled the speed of my Go function
#9I read it and I still don't get it, can someone (re-)explain what the presence of the print() is doing that is helpful for branch prediction (or any other aspect of the CPU)? Update: It seems to be the conditional move, see https://news.ycombinator.com/item?id=37245325
Re: Print(“lol”) doubled the speed of my Go function
#10I read it and I still don't get it, can someone (re-)explain what the presence of the print() is doing that is helpful for branch prediction (or any other aspect of the CPU)? Update: It seems to be the conditional move, see https://news.ycombinator.com/item?id=37245325
I'm in school, so this may be oversimplified, but if the processor/assembly code is predicting the next result, it gets the result faster. The processor only does this prediction with conditional branches. The extra if for printing or finding the min invoke the prediction with the accuracies stated.
This sounds... wrong? Unless ARM64 is designed in an absurd way?
I'd love to see the full disassembly; something seems funny here. If it was x86 I would say it's a conditional move causing this, but I don't know what's going on on ARM.