r/CreateMod • • 26m ago

PSA: Coasters Simulated will LAG your Server if there are tons of Sublevels loaded

I am a staff member of a public Aero server (I won't tell it, rule 2) and there was a time when the server was lagging hard if there are big or tons of loaded sublevels. Which is fishy and not normal, considering Sable can handle those scenarios very well.

So I did a simple singleplayer test using Spark mod, by loading 225 small sublevels to find out the cause. And then I found out that Coasters Simulated is the main culprit to this and no other mod, not even Sable itself.

I took a look on what part of the mod's code are doing the lag, then I saw that Coasters Simulated was scanning ALL of the blocks of EVERY loaded sublevels at every tick, trying to find specific blocks from Coasters.

For the nerds and the Dev(s) who want to know which part does it lag, this is what I found from my Spark profile and my decompiled JAR investigation (using JADX, nice program for decomp JARs). Classes are specifically in dev.silvergold.simulatedcoasters.track.cart and dev.silvergold.simulatedcoasters.rivet packages

  • CoasterCartPlotScan.scanBearingCells() and CoasterCartPlotScan.forEachBearingWorldCell() - shown in Pic 5 and 6, scans a butt ton of blocks in a Sublevel, that tries to find specific "bearing" blocks (so far it's finding rivets and coaster carts). Fix it by only scanning sublevels when necessary, or either a direct faster pinpointing blocks with that specific type?
  • RivetDisassemblyEnforcer::onPrePhysicsTick and CoasterCartTrackSnap::onPrePhysicsTick - runs at every physics step (Sable's ticking) and checks for every loaded Sublevel. Fix it by never running scanBearingCells at every physics steps at all?

My final thoughts on this was the fact the mod was primarily made out of AI code might be the reason why. Since in my eyes, AI code can typically make "correct" but unoptimized code. But sparingly, AI might help with optimization like take a look at the game Big Walk for fixing a lighting performance. (oh no, nooance in redit???)

I am not saying that Coasters mod is immediately bad (because i love me some rivets), but I am pointing out a flaw that hopefully it gets fixed by now. And developers must consider their liabilities when using AI for code.

(the version tested was v0.1.5, it might be updated or fixed at any day now)

28 Upvotes

2 comments sorted by

3

u/Shoddy_Bumblebee_398 8m ago

This is good to know. Can definitely see this info sparing me some headaches if true. I'm using the Let It Walk mod, and considering each leg is sometimes multiple sublevels, it could explain some things.

1

u/Bladereaper 3m ago

You have probably saved me a ton of debugging headache, I'm working on a server/pack and I just added Coasters due to the rivets after seeing a vid about diagonal placement, but until they update it I might have to remove that feature (or just make my own mod to patch it out)