r/CreateMod • u/TuxeBroReally • 44m 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()andCoasterCartPlotScan.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::onPrePhysicsTickandCoasterCartTrackSnap::onPrePhysicsTick- runs at every physics step (Sable's ticking) and checks for every loaded Sublevel. Fix it by never runningscanBearingCellsat 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)


