Create icon indicating copy to clipboard operation
Create copied to clipboard

Implements a cache for train collision checks for better performance

Open stacode123 opened this issue 5 months ago • 5 comments

Implements a cache for train collision checks for better performance Before: https://spark.lucko.me/cgjtsUl25f After: https://spark.lucko.me/p7ZcDxAUFA Criticism welcome. Made with the help of Copilot

World used for testing : world.zip

stacode123 avatar Nov 08 '25 14:11 stacode123

If this works properly this is brilliant @stacode123 and definately needed. We've turned train collisions off entirely to help with lag but thats definately not a fix most servers want to implement.

Using Copilot is a little worrying though because you need to know exactly whats going on for this. Make sure you've tested it thoroughly and used the debugger to step through the code to see whats going on and if it aligns with what you expect.

sleepy-evelyn avatar Nov 08 '25 18:11 sleepy-evelyn

test world has 180 trains more than that would have caused my computer to have a seizure image Will address the comments

stacode123 avatar Nov 08 '25 21:11 stacode123

Performance impact on a server with 475 trains:

image-1.webp

Before: image-21.png

After: image-24.png

stacode123 avatar Nov 09 '25 11:11 stacode123

To be honest it's rare u see such a stark contrast between before and after. A similar number of players are connected to the server as well so the difference likely isn't down to that. :)

sleepy-evelyn avatar Nov 09 '25 16:11 sleepy-evelyn

@Jozufozu Please review the changes :D

stacode123 avatar Nov 09 '25 19:11 stacode123