GothicKit / ZenKit

A re-implementation of file formats used by the early 2000's ZenGin
http://zk.gothickit.dev/
MIT License
44 stars 10 forks source link

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

Closed lmichaelis closed 1 year ago

lmichaelis commented 1 year ago

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.

lmichaelis commented 1 year ago

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 5aed861fe547e40fedd5eb3801191b9323cb60d6):

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?

Try commented 1 year ago

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