forked from tgstation/tgstation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
StonedMC, the bastard love child of GoonPS and CarnMC (tgstation#17987)
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
- Loading branch information
1 parent
2ae6b94
commit 235b79f
Showing
41 changed files
with
1,135 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#define MC_TICK_CHECK ( world.tick_usage > CURRENT_TICKLIMIT ? pause() : 0 ) | ||
// Used to smooth out costs to try and avoid oscillation. | ||
#define MC_AVERAGE_FAST(average, current) (0.7 * (average) + 0.3 * (current)) | ||
#define MC_AVERAGE(average, current) (0.8 * (average) + 0.2 * (current)) | ||
#define MC_AVERAGE_SLOW(average, current) (0.9 * (average) + 0.1 * (current)) | ||
#define NEW_SS_GLOBAL(varname) if(varname != src){if(istype(varname)){Recover();qdel(varname);}varname = src;} | ||
|
||
//SubSystem flags (Please design any new flags so that the default is off, to make adding flags to subsystems easier) | ||
|
||
//subsystem should fire during pre-game lobby. | ||
#define SS_FIRE_IN_LOBBY 1 | ||
|
||
//subsystem does not initialize. | ||
#define SS_NO_INIT 2 | ||
|
||
//subsystem does not fire. | ||
// (like can_fire = 0, but keeps it from getting added to the processing subsystems list) | ||
// (Requires a MC restart to change) | ||
#define SS_NO_FIRE 4 | ||
|
||
//subsystem only runs on spare cpu (after all non-background subsystems have ran that tick) | ||
// SS_BACKGROUND has its own priority bracket | ||
#define SS_BACKGROUND 8 | ||
|
||
//subsystem does not tick check, and should not run unless there is enough time (or its running behind (unless background)) | ||
#define SS_NO_TICK_CHECK 16 | ||
|
||
//Treat wait as a tick count, not DS, run every wait ticks. | ||
// (also forces it to run first in the tick, above even SS_NO_TICK_CHECK subsystems) | ||
// (implies SS_FIRE_IN_LOBBY because of how it works) | ||
// (overrides SS_BACKGROUND) | ||
// This is designed for basically anything that works as a mini-mc (like SStimer) | ||
#define SS_TICKER 32 | ||
|
||
//keep the subsystem's timing on point by firing early if it fired late last fire because of lag | ||
// ie: if a 20ds subsystem fires say 5 ds late due to lag or what not, its next fire would be in 15ds, not 20ds. | ||
#define SS_KEEP_TIMING 64 | ||
|
||
//Calculate its next fire after its fired. | ||
// (IE: if a 5ds wait SS takes 2ds to run, its next fire should be 5ds away, not 3ds like it normally would be) | ||
// This flag overrides SS_KEEP_TIMING | ||
#define SS_POST_FIRE_TIMING 128 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#define TICK_LIMIT_RUNNING 90 | ||
#define TICK_LIMIT_TO_RUN 85 | ||
#define TICK_LIMIT_MC 80 | ||
#define TICK_LIMIT_RUNNING 85 | ||
#define TICK_LIMIT_TO_RUN 80 | ||
#define TICK_LIMIT_MC 84 | ||
#define TICK_LIMIT_MC_INIT 100 | ||
|
||
#define TICK_CHECK ( world.tick_usage > TICK_LIMIT_RUNNING ? stoplag() : 0 ) | ||
#define CHECK_TICK if (world.tick_usage > TICK_LIMIT_RUNNING) stoplag() | ||
#define MC_TICK_CHECK ( world.tick_usage > TICK_LIMIT_RUNNING ? pause() : 0 ) | ||
#define TICK_CHECK ( world.tick_usage > CURRENT_TICKLIMIT ? stoplag() : 0 ) | ||
#define CHECK_TICK if (world.tick_usage > CURRENT_TICKLIMIT) stoplag() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.