8000 [core] stable fiber identity by fwbrasil · Pull Request #1190 · getkyo/kyo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[core] stable fiber identity #1190

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

Merged
merged 1 commit into from
May 14, 2025
Merged

[core] stable fiber identity #1190

merged 1 commit into from
May 14, 2025

Conversation

fwbrasil
Copy link
Collaborator

Problem

When a fiber encounters a child fiber/promise to wait on during execution, IOTask currently resumes the parent in a new IOTask instance after the child completes. Besides the performance cost, this makes the identity of a fiber not stable since it might be executing in a linked IOTask instance if it got suspended by a child fiber. It's a blocker to implement fiber trace dumps for example since the actual execution trace might in a linked IOTask instance.

Solution

Adapt the logic to simply resume the IOTask after a child completes and the execution of the parent needs to resume.

Copy link
Collaborator
@steinybot steinybot left a comment

Choose a reason for hiding this comment

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

This change looks right to me based on what I know although I don't have a full grasp on how the scheduler works.

end if
end run

private inline def nullResult = null.asInstanceOf[A < Ctx & Async & Abort[E]]

override def toString =
s"IOTask(state = ${stateString()}, preempt = ${{ shouldPreempt() }}, finalizers = ${finalizers.size()}, curr = ${curr})"
s"IOTask(id = ${hashCode()}, state = ${stateString()}, preempt = ${{ shouldPreempt() }}, finalizers = ${finalizers.size()}, curr = ${curr})"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you think we should add an id method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I considered exposing it but I haven't seen a good use case yet to justify the API commitment

@fwbrasil fwbrasil merged commit 76e1155 into main May 14, 2025
3 checks passed
@fwbrasil fwbrasil deleted the fiber-child-opt branch May 14, 2025 22:56
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.

3 participants
0