GothicKit / ZenKit

A re-implementation of file formats used by the early 2000's ZenGin

Home Page:http://zk.gothickit.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[v1.1.0] Make the VM's stack more efficient

lmichaelis opened this issue · comments

A std::stack does not have any relevant performance requirements, so it might be unsuitable for a semi high-performance application like the VM. Replacing it with a wrapper around a std::vector, for example should improve performance.

My idea for improving performance is mainly to get rid of std::stack since it has many features not needed for our application. What I've done now is the following (also see 5aed861):

  • Change the type of vm::_m_stack from std::stack to a basic array
  • Add vm::_m_stack_ptr to keep track of the current stack head position

This yields about 5% better performance in RelWithDebugInfo builds as per my brief testing. I'm really not sure if this is a worthwhile improvement but it could benefit performance improvements in the future. Right now, this change would drastically increase memory usage (by around 114kB) in exchange for only minor performance gains.

@Try, since OpenGothic is the largest user of phoenix right now, what do you think?

commented

Hi, @lmichaelis !

Looks good to me.

drastically increase memory usage
by around 114kB

Game OpenGothic about ~1GB :D
0.1Mb is not something to worry about, on ther side of thing 5% is quite good improvement for runtime