-
Notifications
You must be signed in to change notification settings - Fork 125
Sleeping negative delay #2478
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
base: master
Are you sure you want to change the base?
Sleeping negative delay #2478
Conversation
- Remove `sleep` from DMStandard. - Two new opcodes Sleep and BackgroundSleep (which is just `sleep -1`, much faster than popping a `float` off for background sleeps). - Create new lightweight async proc state for sleeping. - Compiler/runtime adjustments to handle new opcodes.
…ive-delay sleeps are done in the same thread
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.
InspectCode found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
|
Haven't tested, but goon definitely uses a lot of background/negative/0 sleeps etc if anyone needs a actual codebase testbench |
|
Tested with this code: Byond: OD master: OD with PR: |
I wanted to take a shot at continuing the work by @Cyberboss in #1539
After making adjustments to fit the latest codebase, I also made additional changes:
forto accept expressions OR certain statements as its incrementor. (apparently you can havefor(var/i=0, i<1, sleep(0)). neat!)(^ Which breaks in current OD, running as a server)
I based the 10/20 sleep scheduling proc/thread thresholds on this test:
Which produces results like this in Byond:
And with this patch you get:
Which is a bit different around when the c loop ends the 2nd time in a row, but is overall more similar compared to the version on master:
I'm not terribly happy with using hashmaps to lookup the thread/proc info by thread/proc id but maybe it's better than storing the negative sleep counts in the procs and thread classes. As for speed, I wasn't able to reproduce the slow startup as described in the OP of #1262 but the idea is to close that issue. Maybe it helps Goon?