brianush1 / zua

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

instruction pointer is problematic

brianush1 opened this issue · comments

The instruction pointer for the VM must be stored per coroutine. However, as D does not offer built-in thread-local storage, it is currently stored in a hashmap with the current Fiber being the key (Solution 1).

An alternative solution (Solution 2), if there were no coroutines in Lua, would be to store a single, global IP.

When comparing 7 runs of solutions 1 and 2, taking the best of 1 and the worst of 2 on the given benchmark.lua file, the times being 375.109 and 184.882 milliseconds respectively, solution 2 outperforms the current solution, being over 2.02 times faster.

More than half the runtime of a given program is spent accessing the instruction pointer. This is not good!