-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Kernel#Sync: pass annotation: keyword to newly created Reactor #348
Conversation
How do you think we should handle the following case? Async(annotation: "foo") do
Sync(annotation: "bar") do |task|
puts task.annotation
end
end |
Could |
Yeah, I considered that too. I think it's a reasonable idea. I think we can take advantage of https://github.com/ioquatix/fiber-annotation/blob/main/lib/fiber/annotation.rb#L31-L45 |
|
Ah wait, that's not a big deal. I'm working on it... |
We can always update the fiber annotation gem to support |
I think this is ready. |
Thanks for your contribution. I understand the value of this change, and think that it's ultimately a good change. However, I want to point out there will be a slight performance hit. Hopefully things like YJIT mitigate it on the fast path (no annotation, existing task). I also had some thoughts around how to present annotations in backtrace, e.g. an annotation is stack frame specific and gets added to exception messages, etc. In other words, there is more work to be done in this area FYI. |
Thanks for the guidance and merging. I'd be a little surprised if the performance hit was even measurable. Annotations in the backtrace sounds like a good idea. Let me know if I can help in any way. |
Annotating the call stack would be an alternative to annotating the fiber. However, for the purpose of Async, I think it wouldn't look that different. We'd need to write up a proposal on <bugs.ruby-lang.org> and propose a similar but non-finer specific interface for "annotate the current stack frame". If it was accepted, then |
https://bugs.ruby-lang.org/issues/19056 was the previous discussion, and at the meeting we discussed having per-call-stack annotations (could be added to exception backtrace too). |
So something like What did you mean by "APM" in that discussion on bugs.ruby-lang.org? If it's advanced power management, I don't know how that relates to this. |
|
Thank you. |
Just for symmetry with
Kernel#Async
. In a library I changed the specs to always run in aSync {...}
block which meant I had to change the main reactor fromAsync(annotation: 'x') { ... }
toAsync(annotation: 'x') { ... }.wait
becauseKernel#Sync
didn't take an annotation. This PR allows it to be justSync(annotation: 'x') { ... }
.