3 ms·
At first glance, this looks like an ordinary interpreter loop [1] using a large switch statement. I didn't think this was all that fast in Go, compared to C. An
by skybrian 8y ago
At first glance, this looks like an ordinary interpreter loop [1] using a large switch statement. I didn't think this was all that fast in Go, compared to C. And yet the JIT version isn't hugely faster and can be slower. Are there performance tricks I'm missing?
[1] https://github.com/perlin-network/life/blob/master/exec/vm.go#L340 https://github.com/perlin-network/life/blob/master/exec/vm.g...
- kzkfkkf 8y ago> I didn't think this was all that fast in Go, compared to C. Maybe it is time to re-evaluate your beliefs then?
- iainmerrick 8y agoDo you mean the JIT engine in this same codebase? It looks like it generates C code and compiles it on the fly. The generated code seems to do manual stack operations, rather than assigning values to variables, and it’s compiled with -O1 so it won’t be heavily optimized. It will be a bit faster than the interpreter because it avoids the opcode dispatch overhead, but if I understand the code right it’s not surprising that it isn’t a ton faster.