-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes yield proc scheduling. Turns sleeps into an opcode #1539
Draft
Cyberboss
wants to merge
15
commits into
OpenDreamProject:master
Choose a base branch
from
Cyberboss:1262-SmartYield
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0e13edb
Add YieldOrder tests
Cyberboss 4f0b534
Fix yield scheduling
Cyberboss 0911a5e
Fix ProcScheduler state poisoning between tests
Cyberboss f0e4f27
Up DMTests timeout x10 for slow Windows runners
Cyberboss 86fb394
Redo sleeping as an opcode
Cyberboss 8d7ebeb
Emit constant folded `BackgroundSleep` opcode on negative values othe…
Cyberboss 8c66a1d
Merge master
Cyberboss 1e4dd81
Clear ProcScheduler state each test run
Cyberboss 7dce998
Merge remote-tracking branch 'upstream/master' into 1262-SmartYield
Cyberboss 38e1ff4
Create `IOpenDreamGameTiming`
Cyberboss e3cecd2
Merge remote-tracking branch 'upstream/master' into 1262-SmartYield
Cyberboss dfc4de4
Correct tick timing for DMTests
Cyberboss 591eb09
Add a failing test
Cyberboss cb18a4e
Fix ProcStatus returned from SleepState
Cyberboss eebf85b
Merge remote-tracking branch 'upstream/master' into 1262-SmartYield
Cyberboss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,20 @@ | ||
// RETURN TRUE | ||
|
||
var/should_be_set = FALSE | ||
|
||
/proc/RunTest() | ||
ASSERT(world.time == 0) | ||
sleep(world.tick_lag) | ||
ASSERT(world.time == 1) | ||
sleep(10) | ||
ASSERT(world.time == 11) | ||
StackCheck() | ||
ASSERT(world.time == 61) | ||
ASSERT(should_be_set) | ||
return TRUE | ||
|
||
/proc/StackCheck() | ||
ASSERT(world.time == 11) | ||
sleep(50) | ||
ASSERT(world.time == 61) | ||
should_be_set = TRUE |
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,58 @@ | ||
var/counter | ||
#define ExpectOrder(n) ASSERT(++counter == ##n) | ||
|
||
/proc/BackgroundSleep(delay, expect) | ||
set waitfor = FALSE | ||
sleep(delay) | ||
world.log << "Expect: [expect]" | ||
ExpectOrder(expect) | ||
|
||
#define MODE_INLINE 0 // spawn | ||
#define MODE_BACKGROUND 1 // set waitfor = FALSE + sleep | ||
#define MODE_RAND 2 // random seeded | ||
|
||
#define TestSleep(delay, expect) if(mode == MODE_INLINE || (mode == MODE_RAND && prob(50))){ spawn(##delay) { ExpectOrder(##expect); } } else { BackgroundSleep(##delay, ##expect); } | ||
|
||
/proc/TestSequence(mode) | ||
counter = 0 | ||
var/start_tick = world.time | ||
|
||
TestSleep(0, 2) | ||
ExpectOrder(1) | ||
sleep(0) | ||
ExpectOrder(3) | ||
|
||
TestSleep(-1, 4) | ||
ExpectOrder(5) | ||
|
||
TestSleep(0, 6) | ||
sleep(-1) | ||
ExpectOrder(7) | ||
|
||
TestSleep(-1, 8) | ||
ExpectOrder(9) | ||
sleep(-1) | ||
ExpectOrder(10) | ||
|
||
TestSleep(1, 13) | ||
sleep(-1) | ||
ExpectOrder(11) | ||
sleep(0) | ||
ExpectOrder(12) | ||
|
||
ASSERT(world.time == start_tick) | ||
|
||
sleep(1) | ||
ExpectOrder(14) | ||
|
||
/proc/RunTest() | ||
world.log << "Inline:" | ||
TestSequence(MODE_INLINE) | ||
|
||
world.log << "Background:" | ||
TestSequence(MODE_BACKGROUND) | ||
|
||
rand_seed(22475) | ||
for(var/i in 1 to 10000) | ||
world.log << "Rand-[i]:" | ||
TestSequence(MODE_RAND) | ||
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using OpenDreamRuntime.Procs; | ||
|
||
using Robust.Shared.IoC; | ||
using Robust.Shared.Timing; | ||
|
||
using System; | ||
|
||
namespace Content.Tests { | ||
sealed class DummyOpenDreamGameTiming : IOpenDreamGameTiming { | ||
|
||
[Dependency] IGameTiming _gameTiming = null!; | ||
|
||
public GameTick CurTick { get; set; } | ||
|
||
public TimeSpan LastTick => _gameTiming.LastTick; | ||
|
||
public TimeSpan RealTime => _gameTiming.RealTime; | ||
|
||
public TimeSpan TickPeriod => _gameTiming.TickPeriod; | ||
|
||
public byte TickRate { | ||
get => _gameTiming.TickRate; | ||
set => _gameTiming.TickRate = value; | ||
} | ||
} | ||
} |
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
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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to up the test timeout because this overran 500ms