Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add task source name #21583

Merged
merged 1 commit into from Sep 4, 2018
Merged

Add task source name #21583

merged 1 commit into from Sep 4, 2018

Conversation

@AgustinCB
Copy link
Contributor

AgustinCB commented Sep 2, 2018

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.


  • ./mach build -d does not report any errors

  • ./mach test-tidy does not report any errors

  • These 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 Reviewable

@highfive
Copy link

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
Copy link

highfive commented Sep 2, 2018

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/task_source/file_reading.rs, components/script/dom/document.rs, components/script/task_source/remote_event.rs, components/script/task_source/user_interaction.rs, components/script/dom/vrdisplay.rs and 13 more
  • @KiChjang: components/script/task_source/file_reading.rs, components/script/dom/document.rs, components/script/task_source/remote_event.rs, components/script/task_source/user_interaction.rs, components/script/dom/vrdisplay.rs and 13 more
@highfive
Copy link

highfive commented Sep 2, 2018

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
let mut throttled_tasks = self.throttled.borrow_mut();
throttled_tasks
.entry(task_source)
.entry(task_source.clone())

This comment has been minimized.

Copy link
@AgustinCB

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.

Copy link
@gterzian

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.

Copy link
@AgustinCB

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!

@AgustinCB
Copy link
Contributor Author

AgustinCB commented Sep 2, 2018

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!

Copy link
Member

gterzian left a comment

Great work! Glad to see someone picking up this code so quickly! Just a few changes requested, and after that @jdm might want to do a final review(and the commits probably can be squashed into one after)...

let mut throttled_tasks = self.throttled.borrow_mut();
throttled_tasks
.entry(task_source)
.entry(task_source.clone())

This comment has been minimized.

Copy link
@gterzian

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.

Copy link
@gterzian

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.

Copy link
@gterzian

gterzian Sep 3, 2018

Member

nit: looks like you can remove this TODO

WorkerEvent,
task,
Some(pipeline_id),
TaskSourceName::DOMManipulation,

This comment has been minimized.

Copy link
@gterzian

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.

Copy link
@gterzian

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.

Copy link
@gterzian

gterzian Sep 4, 2018

Member

I've filed a bit more of an explanation at #21600

ScriptThreadEventCategory::ExitFullscreen,
handler,
pipeline_id,
TaskSourceName::DOMManipulation,

This comment has been minimized.

Copy link
@gterzian
WebVREvent,
task,
Some(pipeline_id),
TaskSourceName::DOMManipulation,

This comment has been minimized.

Copy link
@gterzian

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.

Copy link
@gterzian

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.

Copy link
@gterzian

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

@gterzian
Copy link
Member

gterzian commented Sep 3, 2018

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

  1. ./mach test-wpt /_mozilla/mozilla/task_queue_throttling.any.worker.html
  2. and ./mach test-wpt /_mozilla/mozilla/task_queue_throttling.any.html

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.

@AgustinCB
Copy link
Contributor Author

AgustinCB commented Sep 3, 2018

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.

Copy link
@gterzian

gterzian Sep 3, 2018

Member

that's a nice one, there was indeed no need to unwrap the queued_task right inside the match...

@gterzian
Copy link
Member

gterzian commented Sep 3, 2018

Ok, thanks for giving us context with your commits, I'd say one could have squashed them into two commits:

  1. Task-source: add the TaskSourceName to CommonScriptMsg::Task(consisting of the first two commits).
  2. Task-queue: replace task_category with task_source_name in QueuedTaskConversion(consisting of only the changes to QueuedTaskConversion and the task-queue that relate to replacing the task_category method with task_source)

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 edit option of git rebase and breaking those changes into new smaller commits, later re-squashing them as appropriate in those two mentioned above(same goes for the last two commits, which I think each have parts that would relate to either 1 or 2).

To make it easier, perhaps you could squash all into one commit entitled add the TaskSourceName to CommonScriptMsg::Task and update QueuedTaskConversion and the TaskQueue to use it?

Copy link
Member

gterzian left a comment

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.

Copy link
@gterzian

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)

@AgustinCB AgustinCB force-pushed the AgustinCB:add-task-source-name branch from a8c65e0 to d65ba4f Sep 3, 2018
Copy link
Member

gterzian left a comment

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.

Copy link
@gterzian

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

@gterzian
Copy link
Member

gterzian commented Sep 3, 2018

Thanks! Please squash, and we can then try a full test run on the server...

@AgustinCB AgustinCB force-pushed the AgustinCB:add-task-source-name branch from 9248028 to 222a537 Sep 3, 2018
@AgustinCB
Copy link
Contributor Author

AgustinCB commented Sep 3, 2018

Done!

@gterzian
Copy link
Member

gterzian commented Sep 3, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Sep 3, 2018

Trying commit 222a537 with merge 4b76b2a...

bors-servo added a commit that referenced this pull request Sep 3, 2018
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 3, 2018

💔 Test failed - linux-rel-wpt

@gterzian
Copy link
Member

gterzian commented Sep 3, 2018


{"status": "TIMEOUT", "group": "default", "message": null, "stack": null, "subtest": null, "test": "/_webgl/conformance/context/context-release-upon-reload.html", "line": 199837, "action": "test_result", "expected": "OK"}
{"status": "TIMEOUT", "group": "default", "message": null, "stack": null, "subtest": null, "test": "/_webgl/conformance2/rendering/draw-buffers.html", "line": 199851, "action": "test_result", "expected": "OK"}

#21595
#21596

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?

@AgustinCB
Copy link
Contributor Author

AgustinCB commented Sep 3, 2018

Is there something I can do to make those tests pass?

@gterzian
Copy link
Member

gterzian commented Sep 4, 2018

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

Copy link
Member

gterzian left a comment

One small change...

@@ -46,6 +47,7 @@ impl NetworkingTaskSource {
ScriptThreadEventCategory::NetworkEvent,
Box::new(task),
Some(self.1),
TaskSourceName::Networking,

This comment has been minimized.

Copy link
@gterzian

gterzian Sep 4, 2018

Member

Looks like we missed one case of using the associated const here.

@AgustinCB AgustinCB force-pushed the AgustinCB:add-task-source-name branch from 222a537 to eeaec31 Sep 4, 2018
@highfive highfive removed the S-tests-failed label Sep 4, 2018
Copy link
Member

gterzian left a comment

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.

Copy link
@gterzian

gterzian Sep 4, 2018

Member

nit: typo in the comment with choise...

Update QueuedTaskConversion and the TaskQueue to use it
@AgustinCB AgustinCB force-pushed the AgustinCB:add-task-source-name branch from eeaec31 to e286fdc Sep 4, 2018
@jdm
Copy link
Member

jdm commented Sep 4, 2018

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+

@bors-servo
Copy link
Contributor

bors-servo commented Sep 4, 2018

📌 Commit e286fdc has been approved by jdm

@highfive highfive assigned jdm and unassigned avadacatavra Sep 4, 2018
@bors-servo
Copy link
Contributor

bors-servo commented Sep 4, 2018

Testing commit e286fdc with merge 162826d...

bors-servo added a commit that referenced this pull request Sep 4, 2018
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 -->
@bors-servo
Copy link
Contributor

bors-servo commented Sep 4, 2018

@bors-servo bors-servo merged commit e286fdc into servo:master Sep 4, 2018
1 of 3 checks passed
1 of 3 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
homu Test successful
Details
@gterzian gterzian mentioned this pull request Sep 5, 2018
4 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.