Description
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.