By looking at world.cpu and mc's sleep_delta, we can get a rough prediction of how long we will need to sleep, rather then wake up, see the tick is already overran, sleep, rinse, repeat, cutting down on the amount of sleep()'s used in stoplag (and cutting down the overhead from those sleeps)
This sadly makes stoplag much more aggressive, and things under it much more slow, but the goal is to move most of the things on this to subsystems. Current targets are spacedrift (done), orbits, and throwing.
Basically, they key difference between StonedMC and CarnMC is that when multiple ticks want to run at the same byond tick, we divvy up the tick between the subsystems, rather then allow one subsystem to hog it all.
The key difference between StonedMC and GoonPS is that we allow the subsystems to tell us how to divvy up the tick using flags and priority.
The new SS_ flags allows us to select behaviors that used to be piggybacked as side effects of dynamic wait or default but sometimes unneeded behavior.
Dynamic wait is 100% gone, lower priority and SS_BACKGROUND are better more refined ways of doing this when combined with MC_TICK_CHECK
I have by design never looked at the inners of goonPS, so this is all original code but I know it uses two loops because of comments by goon devs on reddit threads, that design didn't make sense before, but when I can tell a SS how much of a byond tick it is allowed to have, knowing how many need to run this tick is helpful I also know a bit more about how it works from piecing together comments in #vgstation.
Detailed list of changes:
Subsystems now have flags, allowing fine grain control over things like rather or not it processes, inits, rather it's wait is how long between runs (post run timing) or how long between starts, and rather or not late fires should cause the next fire to be earlier.
Mc now has two loops One loop handles queuing shit, one loop handles running shit.
MC now splits up tick allotment rather than first come first serve Subsystems can even request a bigger share using higher priorities. (It will even resume subsystems it paused if other subsystems hadn't used as much as it predicted they might need)
Default fps is now 20 This is related enough to the MC and it's a change that's really long since over due
All code oddities are most likely to be necessities to lower overhead on the mc since it runs every tick
* Starting out on our tgui journey
* God tgui, why do you need to be updated
You're dynamically generated anyway
* Commit of stuff
* Further progress is being made
* Everyone loves buildscripts
* Further modifications to my incredible running script
* Starting to modify the minimap code to be better
* It's going well thusfar, I guess
* What have I done
* RIP minimap
* FUN FUN FUN FUN FUN
* Adds shuttle_manipulator.dmi
MUH HOLOGRAMS
* Is it done? IS IT OVER
* Peer review
* Some bug fixes
* Makes that damn greentext shut up
* Shuttle registration
* Made the Emergency Escape Bar more robust
No climbing on the bar.
* Do not stare into the operation end of the device
* Compile shame
* THE MOST DUMB
* Passive barmaiden
* Emergency shuttle memes
* MORE SAFETY CODE
* Fancy shuttle manipulator icons
* Smoothing it out
* We are going to have a lot of fun with this one
* Independent blobbernauts
* WABBAJACK WABBAJACK
* Message for attempting to authenticate old style
* Angry alert noise is back
* Revert "Independent blobbernauts"
This reverts commit 34d6af7c9c88cfc2864990cb37b586bb90163dd3.
* No parrot sleep plz
* Moves the special shuttle stuff to special.dm
* No Bartender like a Centcom Bartender
* Non-controversial map changes
- Backup shuttle moved closer to Centcom main structure, docking tube
created
- Moved shuttle import landmark to above Centcom main building
- Added shuttle displays to Conference Room
- Squashed the Chapel a bit in Metastation
- Made the docking port on Z2 massive
- Made the docking port on Metastation a lot larger
* Hacks and slashes at Box
A bunch of things are extended and squashed so Box shuttle dock can
support the MetaStation emergency shuttle.
* Some Metastationshit
* Never ending changes
* Wabbajack to TGM
* Modified the bar, I think that's all of them
* Stops Barmaiden wandering around
* More code review
* Whitspace, the bane of us all
* DIE WHITESPACE DIE
* Initial start of lavaland ruin budget system
Weights are dumb, we're gonna use BUDGETS!
To be clear, each round, there will be a budget for ruins.
HERE IS A ROUGH APPROXIMATION OF THE AIMED PROCESS
- Pick a ruin
- Can we afford it? If not, start again.
- Try a bunch of times to place it.
- Did we place it? Good, then reduce our budget accordingly
Does this look a little like syndicate surplus crates? That's the point.
* Subclassery
* Budget based ruin loader is GO
* Cryostasis (with a s)
* Adjusted costs, added no-duplication
* No dupes on the major ruins
* Deleted files, budget is config
* Corrected description
* Fixed ruins failing to load, duplication
* The zoo goldgrub will no longer burrow away
* Space descriptions and names
* No more weird Xenonest loops, should be all good
* Adjusted costs based on feedback
Basically, when atmos (or another dwait subsystem) pauses as it runs to the end of a tick, its suppose to be ran again next mc tick as long as nothing else needs to run. (non-dwait subsystems run next tick regardless, rather than checking for other subsystems first)
The issue is the mc won't run it again, because it was ran less then 75% of SS.wait ago. (a safety I added to prevent lag compounding from trying to make up missed ticks caused by, back in august)
This fixes that, and fixes another issue where if say atmos takes 3ds to process everything, it's next process would be in 5 ds, not 2 ds like it's suppose to be.
So before, a subsystem with dynamic wait enabled, when paused mid run, would have to wait ss.wait until it could resume its run. Where as normally subsystems in these cases get resumed within 3 byond ticks, in most cases, only 1 byond tick.
This makes it so the subsystem resumes next tick, like normal subsystems, but only after every other subsystem has been checked once to see if they need to run, and ran if that's the case. so basically low priority
This setup allows subsystems to pause themselves until next mc fire if they are about to go over a tick, and resume on the next mc tick
It also makes it so we prioritize running subsystems we skipped because there wasn't enough time in the current tick to run them based on their avg tick usage. (as well as subsystems paused mid way thru)
Adds a macro for adding this to non-mc procs. just drop it in the loop. There is a define version as well for if checks if you want to know if you just slept to avoid lag.
This is all inside #if DM_VERSION defines, so once i test that 509 still works to compile/test this should be good to merge
Fixes the mc getting all fucked up during midnight rollover
Mc now tracks the tick_usage of every subsystem, and will skip running an expensive subsystem if we are too close to overrunning in a tick, waiting until next tick, unless that subsystem is excessively past due (because we kept skipping it).
It now assumes that 20% of a tick should be saved for byond to do it's things, and stops running all subsystems once we get to 80% tick usage.
Dynamic wait will only smooth out wait changes over 8 fires if the new wait is lower than the old wait, before it would smooth out wait increases as well as decreases.
The fps throttle system is now 509 only.
The mc will now run every 1ds, no GCD bullshit, as we want to spread things out more.
Offline subsystems will still show their stat message
DS is now rounded to 2 digits, not 3, to make room for the tick percentage bit, and because the 3rd digit was useless and all MoE
See http://www.byond.com/forum/?post=2021963#comment18164837
Higher fps when cpu goes over 120 causes issues. I have it scaling around 100 to give us a buffer, and not going back down until it drops below 75 to avoid it jumping too much.
This is a bit of a mess, but all of it can removed once the bug is fixed on byond's end.