Skip to content

Limit foreground task draining loop in NodePlatform #19937

Closed
@ulan

Description

@ulan

See https://groups.google.com/forum/#!topic/v8-users/tunDe2yVUoQ for the context.

Currently the NodePlatform drains the foreground_tasks_ queue until the queue becomes empty:
while (std::unique_ptr task = foreground_tasks_.Pop()) {
did_work = true;
RunForegroundTask(std::move(task));
}

This does not work well for tasks that re-post themselves. An example of such tasks is incremental marking task that does 1ms marking work and re-posts itself.

With the current loop draining implementation, incremental marking effectively becomes non-incremental because the loop stops only when incremental marking finishes.

I would like to propose to limit the draining loop to the number of tasks that were in the queue at the start of the loop. The re-posted tasks would be processed via libuv, which would give other tasks (like JS code) chance to run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.v8 platformIssues and PRs related to Node's v8::Platform implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions