Repository navigation
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
Follow-up to #26, from the review of swiftwasm#821. With
yieldIntervalset, the drain reads the clock after every job.ContinuousClock.nowgoes through the WASI shim toperformance.now(), and for small jobs that read costs more than the job itself.This PR reads the clock every N jobs instead. N starts at 1 and doubles (up to 256) while less than a quarter of the interval has passed, so slow jobs are still checked after every job, and long runs of small jobs pay for a clock read only now and then. With
yieldInterval == nilnothing changes.Task.yield()hops, Node.js, releasenilyieldIntervalsetTrade-off: if a drain switches from many small jobs to slow ones, up to N - 1 slow jobs can run before the next clock read, so the yield can come later than the interval. N goes back to 1 at the start of every drain.
Testing
make unittestJavaScriptEventLoopbuilds with the Embedded SDK.Task.yield()hops, 3 interleaved runs per build, median of 5 rounds each../Utilities/format.swiftapplied.