-
Notifications
You must be signed in to change notification settings - Fork 157
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
Remove lwt from low level finalise #2064
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,7 +547,7 @@ module Make (Args : Args) = struct | |
|
||
let finalise ~wait t = | ||
match t.stats with | ||
| Some stats -> Lwt.return_ok (`Finalised stats) | ||
| Some stats -> Ok (`Finalised stats) | ||
| None -> ( | ||
let go status = | ||
let start = t.elapsed () in | ||
|
@@ -614,14 +614,14 @@ module Make (Args : Args) = struct | |
let () = Lwt.wakeup_later t.resolver err in | ||
err | ||
in | ||
Lwt.return result | ||
result | ||
in | ||
if wait then | ||
let* status = Async.await t.task in | ||
let status = Async.await t.task in | ||
go status | ||
else | ||
match Async.status t.task with | ||
| `Running -> Lwt.return_ok `Running | ||
| `Running -> Ok `Running | ||
| status -> go status) | ||
Comment on lines
619
to
625
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A solution to the
and then add a new
This way, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this would lead to some code duplication, I'm not sure its worth: its not removing lwt from async and finalise is already the only place in the gc where we return lwt. I'm closing this for now. If you disagree, please open this again. |
||
|
||
let on_finalise t f = | ||
|
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.
I'm a bit concerned about this change -
Lwt_unix.waitpid
blocked the current promise, but allowed for other Lwt promises to run. I think with this change we are blocking all promises in this 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.
Hmm, this is a good question. We do not use
Lwt
for other I/O operations (like inio.ml
) so I'm wondering if this change makes anything that much worse. In the high-level gc api (that is used by Tezos),await
will never be called -- we only checkstatus
. Does that change anything for you?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.
I agree we should avoid doing this as it is blocking the whole process that defeat the purpose of that API
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.
@samoht this function is not called as a part of the high-level api. It only calls
status
, which is already usingUnix.waitpid [ Unix.WNOHANG ] t.pid
.