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 upAdd task source name #21583
Add task source name #21583
Conversation
highfive
commented
Sep 2, 2018
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @avadacatavra (or someone else) soon. |
highfive
commented
Sep 2, 2018
|
Heads up! This PR modifies the following files:
|
highfive
commented
Sep 2, 2018
| let mut throttled_tasks = self.throttled.borrow_mut(); | ||
| throttled_tasks | ||
| .entry(task_source) | ||
| .entry(task_source.clone()) |
This comment has been minimized.
This comment has been minimized.
AgustinCB
Sep 2, 2018
Author
Contributor
I'm not sure this is a good idea.
I thought about refactoring this to use references instead of owned objects, but I didn't felt brave enough and went the easy way.
Any suggestion on what would be better here?
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
•
Member
Besides the larger refactoring you suggest, one could also consider using HashMap.get(&task_source_name), however that would come at the cost of more manual logic involved with checking the returned option and inserting an empty Vec if it is None and so on...
Perhaps the convenience of the entry API is worth a (probably not very expensive)clone?
This comment has been minimized.
This comment has been minimized.
AgustinCB
Sep 3, 2018
Author
Contributor
Yeah, that was my intuition here (i.e. the entry call was worth a clone in an small enum). Thank you for the detailed explanation!
|
I wasn't sure about how to (or if I should) add tests for this. If you think is appropriate, could give you give me a quick explanation on how to do it? Thanks! |
| let mut throttled_tasks = self.throttled.borrow_mut(); | ||
| throttled_tasks | ||
| .entry(task_source) | ||
| .entry(task_source.clone()) |
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
•
Member
Besides the larger refactoring you suggest, one could also consider using HashMap.get(&task_source_name), however that would come at the cost of more manual logic involved with checking the returned option and inserting an empty Vec if it is None and so on...
Perhaps the convenience of the entry API is worth a (probably not very expensive)clone?
| _ => return None, | ||
| } | ||
| } | ||
|
|
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
Member
nit: If you insert the new code(in this case task_source_name) at the same level as the old code(in this case task_category), it makes the diff easier to understand for the reviewer(the diff will also show more clearly the difference between the old and new code, since the entire block wasn't changed in fact, see the diff for the other implementations).
In this case, since all other implementations have task_source_name as the first method, as does the trait signature, there is also a benefit in terms of consistency at keeping it the first(top-most) method for this implementation as well.
| @@ -447,7 +453,12 @@ impl DedicatedWorkerGlobalScope { | |||
| } | |||
| })); | |||
| // TODO: Should use the DOM manipulation task source. | |||
This comment has been minimized.
This comment has been minimized.
| WorkerEvent, | ||
| task, | ||
| Some(pipeline_id), | ||
| TaskSourceName::DOMManipulation, |
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
•
Member
Could you please add a TODO, and file a corresponding issue, pointing out that we should be using a new unshipped-port-message-queue task source that should be used here?
See https://html.spec.whatwg.org/multipage/#unshipped-port-message-queue (I got to this following the spec link just above the fn PostMessage and looking for the task source that would correspond to this specific tasks, it's often mentioned somewhere else than where the task itself is mentioned, often at the bottom of the relevant section...)
| ScriptThreadEventCategory::EnterFullscreen, | ||
| handler, | ||
| pipeline_id, | ||
| TaskSourceName::DOMManipulation, |
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
Member
Please add a NOTE here that the spec mentions running these steps "in parallel", not necessarily as a queued task. For now using the DOMManipulation seems OK however. See Step 7 of https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen
This comment has been minimized.
This comment has been minimized.
| ScriptThreadEventCategory::ExitFullscreen, | ||
| handler, | ||
| pipeline_id, | ||
| TaskSourceName::DOMManipulation, |
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
Member
Same here, see Step 8 of https://fullscreen.spec.whatwg.org/#exit-fullscreen
| WebVREvent, | ||
| task, | ||
| Some(pipeline_id), | ||
| TaskSourceName::DOMManipulation, |
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
•
Member
Please add a NOTE asking whether long-term we want to be using the DOMManipulation task source here. The WebVR spec doesn't seem to point to s specific task source.
| WebSocketEvent, | ||
| task, | ||
| Some(pipeline_id), | ||
| TaskSourceName::Networking, |
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
Member
Please add a TODO, and file an issue, noting that we should be using a dedicated websocket-task-source here, see https://html.spec.whatwg.org/multipage/web-sockets.html#websocket-task-source (I got to this by first looking up this BufferedAmountTask, following the spec link, and then scrolling down until I found the words "The task source for all tasks queued in this section is the WebSocket task source.")
| ScriptThreadEventCategory::WorkletEvent, | ||
| Box::new(task), | ||
| None, | ||
| TaskSourceName::DOMManipulation, |
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
Member
Please add a NOTE that it's unclear from the Spec which task source should be used here, see https://drafts.css-houdini.org/worklets/#dom-worklet-addmodule
|
The CI error looks unrelated https://travis-ci.org/servo/servo/jobs/423696837#L2135, was it building fine on your machine? By the way, the relevant test that you might want to run on your machine to see if it passes, would be
I would tend to think that no new test would be required for this change, as the above, and many other tests in the wpt suite, should cover it. You probably don't want to run the entire suite on your machine, as there will be lots of spurious timeouts, those can be run on the server from here. |
|
Yes, it builds correctly on local. And both test succeed on local too! |
| @@ -82,7 +88,8 @@ impl<T: QueuedTaskConversion> TaskQueue<T> { | |||
| for msg in to_be_throttled { | |||
| // Categorize tasks per task queue. | |||
| let (worker, category, boxed, pipeline_id, task_source) = match msg.into_queued_task() { | |||
| Some((worker, category, boxed, pipeline_id, task_source)) => (worker, category, boxed, pipeline_id, task_source), | |||
| Some(queued_task) => | |||
| queued_task, | |||
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
Member
that's a nice one, there was indeed no need to unwrap the queued_task right inside the match...
|
Ok, thanks for giving us context with your commits, I'd say one could have squashed them into two commits:
However since the third commit also contains some smaller changes like 5c432f5#diff-1879ac6bd5d567e2aa43529d33474677L274 that are corrections of the previous commit, I think you might have a bit of a hard time with git to dis-entangle those changes using the To make it easier, perhaps you could squash all into one commit entitled |
|
One additional nit |
| Some((worker, category, boxed, pipeline_id)) => (worker, category, boxed, pipeline_id), | ||
| let (worker, category, boxed, pipeline_id, task_source) = match msg.into_queued_task() { | ||
| Some(queued_task) => | ||
| queued_task, |
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
•
Member
nit: I think this one would belong on the same line right after the =>, or has rustfmt formatted it that way?
(not saying you should run rustfmt if you haven't, since that would likely introduce other changes unrelated to the present commits)
a8c65e0
to
d65ba4f
|
One more set of nits :) |
| @@ -40,7 +40,8 @@ impl TaskSource for UserInteractionTaskSource { | |||
| let msg = MainThreadScriptMsg::Common(CommonScriptMsg::Task( | |||
| ScriptThreadEventCategory::InputEvent, | |||
| Box::new(canceller.wrap_task(task)), | |||
| Some(self.1) | |||
| Some(self.1), | |||
| TaskSourceName::UserInteraction, | |||
This comment has been minimized.
This comment has been minimized.
gterzian
Sep 3, 2018
•
Member
For all the changes inside implementations of TaskSource, like this one, I think you can use the associated const directly, doing something like UserInteractionTaskSource::NAME
See https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants
|
Thanks! Please squash, and we can then try a full test run on the server... |
9248028
to
222a537
|
Done! |
|
@bors-servo try |
Add task source name Refactor `CommonScriptMsg::Task` to include `TaskSourceName`. Sorry for the delay, between doing this after work and the time I spent trying to ramp up on the project, it took me a bit longer than I expected. Test still don't pass in local, but they fail the same way on master, so I guess it's ok. I may have forgotten something, I refactored mostly the stuff that the compiler complained about. Please let me know if I missed anything. I tried to dump my thought process on the commit messages, so feel free to go commit by commit to understand context. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #21527 - [ ] There are tests for these changes OR - [x] These changes do not require tests because it's mostly refactor, no new behavior added. <!-- 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/21583) <!-- Reviewable:end -->
|
|
Only a few intermittent failure(which you can find by going to http://build.servo.org/grid and looking at the commit corresponding to what is announced at #21583 (comment)) @jdm r? |
|
Is there something I can do to make those tests pass? |
|
I don't think so, those are tests that will fail on occasion and that aren't related to the current changes(I think). We can wait for @jdm to give the greenlight, or another round of review if necessary... |
|
One small change... |
| @@ -46,6 +47,7 @@ impl NetworkingTaskSource { | |||
| ScriptThreadEventCategory::NetworkEvent, | |||
| Box::new(task), | |||
| Some(self.1), | |||
| TaskSourceName::Networking, | |||
This comment has been minimized.
This comment has been minimized.
222a537
to
eeaec31
|
One more thing that slipped my attention earlier... |
| @@ -517,7 +518,14 @@ impl VRDisplay { | |||
| let task = Box::new(task!(handle_vrdisplay_raf: move || { | |||
| this.root().handle_raf(&sender); | |||
| })); | |||
| js_sender.send(CommonScriptMsg::Task(WebVREvent, task, Some(pipeline_id))).unwrap(); | |||
| // NOTE: WebVR spec doesn't specify what task source we should use. Is | |||
| // dom-manipulation a good choise long term? | |||
This comment has been minimized.
This comment has been minimized.
Update QueuedTaskConversion and the TaskQueue to use it
eeaec31
to
e286fdc
|
Great work @AgustinCB, and thanks for reviewing the changes, @gterzian! I've looked them over and everything looks like what I expected :) @bors-servo r+ |
|
|
Add task source name Refactor `CommonScriptMsg::Task` to include `TaskSourceName`. Sorry for the delay, between doing this after work and the time I spent trying to ramp up on the project, it took me a bit longer than I expected. Test still don't pass in local, but they fail the same way on master, so I guess it's ok. I may have forgotten something, I refactored mostly the stuff that the compiler complained about. Please let me know if I missed anything. I tried to dump my thought process on the commit messages, so feel free to go commit by commit to understand context. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #21527 - [ ] There are tests for these changes OR - [x] These changes do not require tests because it's mostly refactor, no new behavior added. <!-- 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/21583) <!-- Reviewable:end -->
|
|
AgustinCB commentedSep 2, 2018
•
edited by SimonSapin
Refactor
CommonScriptMsg::Taskto includeTaskSourceName.Sorry for the delay, between doing this after work and the time I spent trying to ramp up on the project, it took me a bit longer than I expected.
Test still don't pass in local, but they fail the same way on master, so I guess it's ok.
I may have forgotten something, I refactored mostly the stuff that the compiler complained about. Please let me know if I missed anything.
I tried to dump my thought process on the commit messages, so feel free to go commit by commit to understand context.
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThese changes fix #21527
There are tests for these changes OR
These changes do not require tests because it's mostly refactor, no new behavior added.
This change is