Engine Optimizations #1707
assemblaj
started this conversation in
Engine development
Replies: 1 comment
-
I was just looking at this and it looks like, while we already iterate over characters through pointers (charList), we do a lot of copying the Projectile and Explod data when we iterate over them. Update: This is the January 22nd Nightly with 1000 projectiles: And this is after optimizing the usage of "range" in projectile loops: 6 vs 35fps. Of course a scenario with 1000 projectiles won't happen very often, but this still seems worth doing. Couldn't extract the same gains from explods though, so those don't seem as bad. |
Beta Was this translation helpful? Give feedback.
0 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
Just making a thread to document small engine optimizations I find.
Testing IWTBT Ryu 4v4 on a low end PC and taking profile snapshots when IWTBTRyu does the Hadoken Wave, which is arguably his most problematic move, and the Projectile.clsn function would case a lot of trouble


This turned out to be because of the range statement over all of the character's projectiles in that function. I'm not exactly sure why. Anyway, this was fixed by replacing the range with a regular for loop that access the projectile through a pointer:
The Systen,charUpdate and System.action calls shown in the above image have issues with the exact same thing. I fixed it there too, but I haven't profiled it yet.
Not exactly sure why the graphics side of things went ahead and ate up any kind of performance gains we would've seen from this lol, but I know for sure that that Hadoken Wave that IWTBT Ryu does is more likely to play out without frameskipping with this fix.
In the future, it might be a worthwhile idea to create helper functions that iterate over each item in our asset slices and perform this behavior while taking a function to perform on each individual item, like for example this maybe:
To prevent having to copy/paste this logic everywhere. Of course some loops require more complex logic such that this wouldn't be applicable, but I think something like this would work in most cases.
Beta Was this translation helpful? Give feedback.
All reactions