Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upmeasure blocked layout queries #23115
Conversation
highfive
commented
Mar 27, 2019
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @jdm (or someone else) soon. |
highfive
commented
Mar 27, 2019
|
Heads up! This PR modifies the following files:
|
highfive
commented
Mar 27, 2019
|
This is the right idea, but we're currently sharing too many atomic values that should be independent. As for the panic not triggering, what pages are you testing against? |
| @@ -673,7 +682,12 @@ impl LayoutThread { | |||
| self.paint_time_metrics.maybe_set_metric(epoch, paint_time); | |||
| true | |||
| }, | |||
| Request::FromScript(msg) => self.handle_request_helper(msg, possibly_locked_rw_data), | |||
| Request::FromScript(msg) => { | |||
| self.busy.store(true, Ordering::Relaxed); | |||
This comment has been minimized.
This comment has been minimized.
jdm
Mar 29, 2019
Member
Rather than only marking when we process script messages, we should be setting this to false before the select! and setting it to true immediately afterwards.
This comment has been minimized.
This comment has been minimized.
| @@ -865,6 +879,7 @@ impl LayoutThread { | |||
| self.webrender_api.clone_sender(), | |||
| self.webrender_document, | |||
| info.paint_time_metrics, | |||
| self.busy.clone(), | |||
This comment has been minimized.
This comment has been minimized.
jdm
Mar 29, 2019
Member
We should be passing an AtomicBoolean that is stored in LayoutThreadInit, rather than cloning the one that is used by the current layout thread.
This comment has been minimized.
This comment has been minimized.
jdm
Apr 16, 2019
Member
My previous comment here is still valid - there's now a member of LayoutThreadInit that we should be passing here instead.
|
|
||
| // TODO pylbrecht | ||
| // write meaningful docstring | ||
| layout_thread_is_busy: Arc<AtomicBool>, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
pylbrecht
Mar 31, 2019
Author
Contributor
Well, the busy flag is created in UnprivilegedPipelineContent::start_all() and passed via clone() to the layout and script thread. I'm not quite sure how to retain the relationship between the two threads, when creating Windows in ScriptThread::load(), unless storing the busy flag in ScriptThread itself.
This comment has been minimized.
This comment has been minimized.
jdm
Apr 1, 2019
Member
You're right, but I think that we can store it as a member of InProgressLoad instead.
| @@ -2857,6 +2864,7 @@ impl ScriptThread { | |||
| self.microtask_queue.clone(), | |||
| self.webrender_document, | |||
| self.webrender_api_sender.clone(), | |||
| self.layout_thread_is_busy.clone(), | |||
This comment has been minimized.
This comment has been minimized.
jdm
Mar 29, 2019
Member
Each Window should get its own busy boolean, since there is a 1:1 window:layout thread ratio.
This comment has been minimized.
This comment has been minimized.
pylbrecht
Mar 31, 2019
•
Author
Contributor
Does this mean there is a separate layout thread for every window? To me it looks like n:1 window:layout thread, but please correct me if I'm wrong.
This comment has been minimized.
This comment has been minimized.
| // TODO pylbrecht | ||
| // write meaningful docstring | ||
| /// | ||
| pub layout_thread_is_busy: Arc<AtomicBool>, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
pylbrecht
Apr 7, 2019
•
Author
Contributor
I feel like storing the busy flag in InitialScriptState is the only way of passing it to argument to ScriptThreadFactory::create().
If I would create it further down the line, it would not be shared across the layout and script thread. Or am I missing something here?
Just the one in this comment so far. Any web pages that are definitely creating blocked layout queries? |
|
If you modify that page to do the layout modification and query in a loop and also add a looping CSS animation/transition, I would expect that to hit the case where the layout query starts while the layout thread is processing an animation tick from the compositor. |
|
With my latest changes the only thing remaining should be creating appropriate output in Any specifics on how I should format the output? |
|
I verified my changes by running Content of <!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<div id="test">
test
</div>
<script>
setInterval(function() {
for (i = 0; i < 100; i++) {
document.getElementById("test").getBoundingClientRect();
}
}, 200);
setInterval(function() {
for (i = 0; i < 100; i++) {
document.getElementById("test").style.color = "blue";
}
}, 250);
</script>
</body>
</html>``` |
1beeef5
to
3f4f463
|
@pylbrecht Huh, does that page generate reports of blocked layout queries? It shouldn't as far as I can tell :< |
|
Actually, I think I'm wrong - the layout thread could be busy finishing up creating the display list for the previous frame while the script thread is trying to perform a new layout query in the next frame. |
3f4f463
to
858011c
Yes, it does.
I hope so, because otherwise just thinking of debugging this makes me anxious. |
| @@ -865,6 +879,7 @@ impl LayoutThread { | |||
| self.webrender_api.clone_sender(), | |||
| self.webrender_document, | |||
| info.paint_time_metrics, | |||
| self.busy.clone(), | |||
This comment has been minimized.
This comment has been minimized.
jdm
Apr 16, 2019
Member
My previous comment here is still valid - there's now a member of LayoutThreadInit that we should be passing here instead.
|
|
||
| writeln!(&mut lock, "_url_\t_blocked layout queries_").unwrap(); | ||
| for (url, count) in &self.blocked_layout_queries { | ||
| writeln!(&mut lock, "{}\t{}", url, count).unwrap(); |
This comment has been minimized.
This comment has been minimized.
| @@ -46,6 +46,11 @@ pub enum ProfilerMsg { | |||
| ), | |||
| /// Message used to force print the profiling metrics | |||
| Print, | |||
|
|
|||
| // TODO pylbrecht | |||
| // write meaningful docstring | |||
This comment has been minimized.
This comment has been minimized.
jdm
Apr 16, 2019
Member
/// Report a layout query that could not be processed immediately for a particular URL.
| @@ -202,6 +203,8 @@ struct InProgressLoad { | |||
| navigation_start_precise: u64, | |||
| /// For cancelling the fetch | |||
| canceller: FetchCanceller, | |||
| /// Flag to indicate if the layout thread is busy handling a request. | |||
This comment has been minimized.
This comment has been minimized.
|
Oh wow.. and I'm sitting here like "Why is this not merged yet?". That's really embarrassing.. (I even left a I pushed the suggested changes and will drop an example output in the comments on the weekend. Busy schedule during the week. |
|
I ran the command
The longer I wait, the more the counter of blocked layout queries increases. |
|
@bors-servo r+ |
|
|
measure blocked layout queries <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19797 <!-- Either: --> - [ ] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23115) <!-- Reviewable:end -->
|
|
pylbrecht commentedMar 27, 2019
•
edited
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is