Skip to content
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

fix io task runtime tracking #314

Merged
merged 2 commits into from
May 3, 2024
Merged

fix io task runtime tracking #314

merged 2 commits into from
May 3, 2024

Conversation

fwbrasil
Copy link
Collaborator

@fwbrasil fwbrasil commented May 3, 2024

This is a bug introduced by #278. I noticed it while testing the new scheduler under stress. I'm not sure how to introduce an automated test for this given that it's a performance issue and this code isn't very testable in isolation. I've tried designing a benchmark to measure preemption performance a few times unsuccessfully.

@@ -49,7 49,7 @@ private[kyo] class IOTask[T](
k.command match
case Promise(p) =>
this.interrupts(p)
val runtime = (clock.currentMillis() - startMillis).toInt
val runtime = (clock.currentMillis() - startMillis this.runtime()).toInt
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario happens when the fiber/io task suspends because of an async boundary. Here, runtime should contain the time spent on the current execution plus all of the scheduling time the fiber got before it.

@@ -12,7 12,7 @@ class Scheduler {

def schedule(t: Task): Unit = {
JSExecutionContext.queue.execute { () =>
if (t.run(0, clock) == Task.Preempted)
if (t.run(clock.currentMillis(), clock) == Task.Preempted)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another fix.

@fwbrasil fwbrasil merged commit d89f10f into main May 3, 2024
3 checks passed
@fwbrasil fwbrasil deleted the fix-io-task-runtime branch May 14, 2024 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants