-
Notifications
You must be signed in to change notification settings - Fork 30k
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
src: limit foreground tasks draining loop #19987
Changes from 1 commit
66a7421
4dbc4aa
c435401
167ae0e
f46763b
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 |
---|---|---|
|
@@ -66,9 +66,9 @@ class PerIsolatePlatformData : | |
void ref(); | ||
int unref(); | ||
|
||
// Returns true iff work was dispatched or executed. | ||
// New tasks that are posted during flushing of the queue are postponed until | ||
// the next flushing. | ||
// Returns true iff work was dispatched or executed. New tasks that are | ||
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. Nit: s/iff/if. 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. @apapirovski I guess these were intentional? 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. Yeah but I know the meaning and I didn't even think of it until you mentioned it... but maybe that just reflects badly on me... 🤔 😆 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 guess what I'm saying: I don't think this is the place for But I'm not going to object if someone prefers this. It's a low priority thing for me. 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. Done. The |
||
// posted during flushing of the queue are postponed until the next | ||
// flushing. | ||
bool FlushForegroundTasksInternal(); | ||
void CancelPendingDelayedTasks(); | ||
|
||
|
@@ -133,7 +133,10 @@ class NodePlatform : public MultiIsolatePlatform { | |
double CurrentClockTimeMillis() override; | ||
v8::TracingController* GetTracingController() override; | ||
|
||
void FlushForegroundTasks(v8::Isolate* isolate); | ||
// Returns true iff work was dispatched or executed. New tasks that are | ||
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. Same here, s/iff/if 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. Done. |
||
// posted during flushing of the queue are postponed until the next | ||
// flushing. | ||
bool FlushForegroundTasks(v8::Isolate* isolate); | ||
|
||
void RegisterIsolate(IsolateData* isolate_data, uv_loop_t* loop) override; | ||
void UnregisterIsolate(IsolateData* isolate_data) override; | ||
|
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.
Doesn't this line preserve the bug? Because, even though you swap the queue before draining it, you're still running this loop forever if new tasks are constantly added to the original queue
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.
The inspector posts foreground tasks and requires that they are all processed before going to the outer loop.
AFAIK this code runs only when the inspector is active and the program is paused. The normal libuv tasks are not processed here. Latency shouldn't be an issue.
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.
My understanding is that the original bug this is trying to fix (#19937) is that there are cases where foreground tasks can add additional tasks to the queue. The bug was fixed by freezing the queue inside of FlushForegroundTasks, but this line of code I'm commenting on appears to loop THAT CALL so that the freeze fix doesn't actually help anything. It still will run forever, if foreground tasks add themselves.
Unless there's more than one place where
FlushForegroundTasks
is being called, and that's not an issue for this line?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.
There is certainly more than one place. This particular line addresses a very specific interaction.