I’m now interested in improving the performance of Julia code that emulates a finite state machine. It reads input data byte by byte and branches based on it. A branch looks like this:
byte = data[p+=1] if byte in 0x30:0x39 # do something... @goto state7 elseif byte in 0x2e:0x2e # do something... @goto state2 else @goto exit end
Recently I read a blog post that says computed goto (or labels as values) is used to improve the performance of virtual machines of interpreted languages such as Python. It looks very similar to what I do in FSM code and I’d like to try it in Julia. Julia also has
@goto statement but I have no idea whether it is possible to do the same thing in Julia. #5410 may be related but not the same. If I can do, the code may look like:
byte = data[p+=1] @goto dispatch[byte] @label number # do something... @goto state7 @label dot # do something... @goto state2 @label default @goto exit
I’m not sure whether it improves the performance, but if so, I’d like to introduce it in Automa.jl.