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

Introduce task queues, and throttling performance timeline tasksource #21388

Merged
merged 2 commits into from Aug 30, 2018

Conversation

@gterzian
Copy link
Member

gterzian commented Aug 12, 2018


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #19997 (github issue number if applicable).
  • There are tests for these changes OR
  • These changes do not require tests because _____

This change is Reviewable

@highfive
Copy link

highfive commented Aug 12, 2018

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/script_thread.rs, components/script/lib.rs, components/script/task_queue.rs
  • @KiChjang: components/script/script_thread.rs, components/script/lib.rs, components/script/task_queue.rs
@highfive
Copy link

highfive commented Aug 12, 2018

warning Warning warning

  • These commits include an empty title element (<title></title>). Consider adding appropriate metadata.
  • These commits modify unsafe code. Please review it carefully!
@gterzian gterzian force-pushed the gterzian:introduce_task_queues branch from 71f096c to e91271c Aug 12, 2018
@gterzian
Copy link
Member Author

gterzian commented Aug 12, 2018

@jdm this is sort of a first draft on the "task-queue" concept, let me know what you think...

@gterzian gterzian force-pushed the gterzian:introduce_task_queues branch 2 times, most recently from dd5170a to 9b886e6 Aug 12, 2018
@gterzian
Copy link
Member Author

gterzian commented Aug 12, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Aug 12, 2018

Trying commit 9b886e6 with merge 551a6fc...

bors-servo added a commit that referenced this pull request Aug 12, 2018
Introduce task queues, and throttling performance timeline tasksource

<!-- 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: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #19997 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/21388)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 12, 2018

@gterzian gterzian force-pushed the gterzian:introduce_task_queues branch 2 times, most recently from e0b521a to 184c69c Aug 13, 2018
@gterzian
Copy link
Member Author

gterzian commented Aug 13, 2018

Last commit is an attempt at #20723, with one caveat, which is that we'll warn! also if the event-loop is simply idle, not just when it's blocked. It is however significantly simpler than using an actual queued task to measure responsiveness...

@gterzian gterzian force-pushed the gterzian:introduce_task_queues branch from 8eb1ad9 to c9235d8 Aug 13, 2018
@gterzian
Copy link
Member Author

gterzian commented Aug 14, 2018

I'm looking into making this TaskQueue a bit more generic, so that it could be used for the worker event-loops as well(whose execution is currently 'one task per iteration', so will require some changes to 'batch' task per iteration like the script-thread does, so that we can have a concept of a 'busy' event-loop)...

@jdm jdm assigned jdm and unassigned gw3583 Aug 14, 2018
fn recv_tasks(&self) -> Vec<WorkerScriptMsg> {
self.receiver.try_iter().map(|msg|{
let (linked_worker, script_msg) = msg;
let _ar = AutoWorkerReset::new(&*self.dedicated_scope, linked_worker);

This comment has been minimized.

@gterzian

gterzian Aug 15, 2018

Author Member

I think this is actually not going to work, since we should only do the AutoWorkerReset 'right before' handling a particular event...

@gterzian gterzian force-pushed the gterzian:introduce_task_queues branch 5 times, most recently from a4a62ad to 5a7bb16 Aug 15, 2018
@gterzian
Copy link
Member Author

gterzian commented Aug 15, 2018

@jdm This one took me quite far down the rabbit hole, and it is finally ready for review.

Main problems encountered:

  1. CommonScriptMsg::Task is hidden inside different structures of messages for each event-loop, so had to define a trait of operations of how to get it 'in and out' of the messages the event-loops expect.
  2. The worker event-loop doesn't have the luxury of receiving messages from the constellation and other parallel components, so it would actually block on the select in the case that there are throttled tasks ready for processing, but there are no new messages coming in. So I had to add a way to wake-up the event-loop in such a case.
  3. The TrustedWorkerAddress used by the dedicated worker was really a major headache, because it is basically a piece of data that needs to be passed along with the task, and the other event-loops don't have something similar. So QeueudTask has an Option<TrustedWorkerAddress> as a result... I also replaced the tuple (TrustedWorkerAddress, WorkerScriptMsg) with a variant of a new DedicatedWorkerScriptMsg, which is simply easier to work with.
  4. On the way, I removed the generic params of (Trusted<T>, CommonScriptMsg) from the SendableWorkerScriptChan because they weren't actually being used, and they would make the above very hard to actually do, so they now just expect a DedicatedWorkerScriptMsg...
@gterzian gterzian force-pushed the gterzian:introduce_task_queues branch from 5a7bb16 to 07375b7 Aug 15, 2018
@gterzian
Copy link
Member Author

gterzian commented Aug 16, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Aug 16, 2018

Trying commit 07375b7 with merge ab43f9a...

@jdm
Copy link
Member

jdm commented Aug 30, 2018

Just waiting on squashing into the two commits now.

@jdm
Copy link
Member

jdm commented Aug 30, 2018

@bors-servo delegate=gterzian

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

✌️ @gterzian can now approve this pull request

@gterzian gterzian force-pushed the gterzian:introduce_task_queues branch from 2b13994 to 029715a Aug 30, 2018
@gterzian
Copy link
Member Author

gterzian commented Aug 30, 2018

@bors-servo r=jdm

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

📌 Commit 029715a has been approved by jdm

@gterzian
Copy link
Member Author

gterzian commented Aug 30, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

💡 This pull request was already approved, no need to approve it again.

  • There's another pull request that is currently being tested, blocking this pull request: #21523
@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

📌 Commit 029715a has been approved by gterzian

@gterzian
Copy link
Member Author

gterzian commented Aug 30, 2018

@bors-servo r=jdm (though it didn't trigger the build first time, but that's not the case it seems)

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

💡 This pull request was already approved, no need to approve it again.

  • There's another pull request that is currently being tested, blocking this pull request: #21523
@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

📌 Commit 029715a has been approved by jdm

@gterzian
Copy link
Member Author

gterzian commented Aug 30, 2018

either this or #21325 will require a rebase anyhow...

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

Testing commit 029715a with merge 1ee3dee...

bors-servo added a commit that referenced this pull request Aug 30, 2018
Introduce task queues, and throttling performance timeline tasksource

<!-- 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: -->
- [ ] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors
- [ ] These changes fix #19997 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- 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/21388)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

💔 Test failed - mac-rel-css1

@jdm
Copy link
Member

jdm commented Aug 30, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

@bors-servo bors-servo merged commit 029715a into servo:master Aug 30, 2018
2 of 4 checks passed
2 of 4 checks passed
Taskcluster (pull_request) TaskGroup: failure
Details
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@gterzian gterzian deleted the gterzian:introduce_task_queues branch Jan 7, 2020
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.

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