{"action":"created","issue":{"url":"https://api.github.com/repos/servo/servo/issues/10110","repository_url":"https://api.github.com/repos/servo/servo","labels_url":"https://api.github.com/repos/servo/servo/issues/10110/labels{/name}","comments_url":"https://api.github.com/repos/servo/servo/issues/10110/comments","events_url":"https://api.github.com/repos/servo/servo/issues/10110/events","html_url":"https://github.com/servo/servo/issues/10110","id":142508028,"number":10110,"title":"Dynamically switch to sequential layout if only a small amount of reflow needs to happen","user":{"login":"pcwalton","id":157897,"avatar_url":"https://avatars.githubusercontent.com/u/157897?v=3","gravatar_id":"","url":"https://api.github.com/users/pcwalton","html_url":"https://github.com/pcwalton","followers_url":"https://api.github.com/users/pcwalton/followers","following_url":"https://api.github.com/users/pcwalton/following{/other_user}","gists_url":"https://api.github.com/users/pcwalton/gists{/gist_id}","starred_url":"https://api.github.com/users/pcwalton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pcwalton/subscriptions","organizations_url":"https://api.github.com/users/pcwalton/orgs","repos_url":"https://api.github.com/users/pcwalton/repos","events_url":"https://api.github.com/users/pcwalton/events{/privacy}","received_events_url":"https://api.github.com/users/pcwalton/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/servo/servo/labels/A-browserhtml/P2","name":"A-browserhtml/P2","color":"d7e102"},{"url":"https://api.github.com/repos/servo/servo/labels/A-layout/uncategorized","name":"A-layout/uncategorized","color":"d7e102"},{"url":"https://api.github.com/repos/servo/servo/labels/B-interesting-project","name":"B-interesting-project","color":"e102d8"},{"url":"https://api.github.com/repos/servo/servo/labels/E-less%20easy","name":"E-less easy","color":"02e10c"},{"url":"https://api.github.com/repos/servo/servo/labels/I-perf-slow","name":"I-perf-slow","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2016-03-22T00:15:36Z","updated_at":"2016-05-10T22:37:30Z","closed_at":null,"body":"Parallel layout overhead is overkill if only a small number of nodes need to be reflowed. In the extreme case, if one chain of nodes from parent to child needs to be reflowed, then parallel layout cannot help at all since it's sequentialized, and all of the traversal code is pure overhead!\r\n\r\nThe easiest way to solve this, I think, would be to have an atomic counter of the number of nodes that were discovered to be dirty (`incremental.rs` can compute this, perhaps) and have the layout thread consult that number. If below a threshold (8? wild guess) then parallel layout will not be spawned. Note that we don't want this to regress performance on pages that have a small number of nodes but lots of reflow to do: consider four paragraphs of 10,000 words each, for instance, which has a small number of nodes but is the ideal case for parallel layout. So we'll probably need a couple of heuristics here and tune appropriately.\r\n\r\ncc @paulrouget "},"comment":{"url":"https://api.github.com/repos/servo/servo/issues/comments/218312676","html_url":"https://github.com/servo/servo/issues/10110#issuecomment-218312676","issue_url":"https://api.github.com/repos/servo/servo/issues/10110","id":218312676,"user":{"login":"metajack","id":28357,"avatar_url":"https://avatars.githubusercontent.com/u/28357?v=3","gravatar_id":"","url":"https://api.github.com/users/metajack","html_url":"https://github.com/metajack","followers_url":"https://api.github.com/users/metajack/followers","following_url":"https://api.github.com/users/metajack/following{/other_user}","gists_url":"https://api.github.com/users/metajack/gists{/gist_id}","starred_url":"https://api.github.com/users/metajack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/metajack/subscriptions","organizations_url":"https://api.github.com/users/metajack/orgs","repos_url":"https://api.github.com/users/metajack/repos","events_url":"https://api.github.com/users/metajack/events{/privacy}","received_events_url":"https://api.github.com/users/metajack/received_events","type":"User","site_admin":false},"created_at":"2016-05-10T22:37:30Z","updated_at":"2016-05-10T22:37:30Z","body":"You can test how this affects browser.html by running with `-y 1`. I'm not sure why this is a P2 bhtml bug though. It seems like this would have minimal impact.\r\n\r\nNote that we can start layout before the whole DOM is loaded. Specifically we start layout after N milliseconds where N is some small constant like 12 or so. So whatever heuristics we want will be applied to whatever DOM we get in that timeframe, although as we get more we can obviously run layout with different numbers of threads on subsequent passes.\r\n\r\nA first pass implementation of this could just wait until the DOM is fully realized, do the calculation and just make further layouts single threaded. Then in later improvements we can start trying to make this decision earlier."}}