Navigation Menu

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

Restructure content process shutdown ack with threaded sender #23972

Merged

Conversation

gterzian
Copy link
Member

@gterzian gterzian commented Aug 15, 2019

Recycling some work from #23909


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (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

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/htmliframeelement.rs, components/constellation/pipeline.rs, components/script/dom/windowproxy.rs, components/script/script_thread.rs
  • @cbrewster: components/constellation/pipeline.rs
  • @KiChjang: components/script/dom/htmliframeelement.rs, components/script/dom/windowproxy.rs, components/script/script_thread.rs, components/script_traits/lib.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Aug 15, 2019
@highfive
Copy link

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@gterzian
Copy link
Member Author

gterzian commented Aug 15, 2019

This is another recycled commit from the big ipc experiment over at #23909

In this case, it restructures the "wait for content to shutdown" pattern, in the following way:

  1. Since it's only used in multiprocess mode, and the "waiting" is done from the "main thread" in the content process, it seems like a threaded channel, created at the point of use, will suffice.
  2. I remove the "wait on layout" part, since the script-thread will itself wait on layout to shutdown each time it shuts down a layout thread, so it seems to me the main-thread only needs to wait on script?
  3. Since dropping the only sender in existence for that channel will already wake-up the receiver, it seems unnecessary to send an explicit message. Instead, we just store the sender on the script-thread, and it will drop along with it when it exits and notify the main thread(of the content-process).

@asajeffrey r?

@jdm
Copy link
Member

jdm commented Aug 15, 2019

r? @asajeffrey

@highfive highfive assigned asajeffrey and unassigned nox Aug 15, 2019
Copy link
Member

@asajeffrey asajeffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by these changes. Replacing an IPC channel by a crossbeam channel IO can understand, since the channel never leaves the process. But AFAICT the channel is being used as a latch, we're never actually sending a message on it?

let signal = content_process_shutdown_port.recv();
// When the script-thread drops the sender,
// we expect to receive an Err(_).
assert!(signal.is_err());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps an error! log rather than a panic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, forgot this is in the constellation thread...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not in the constellation thread actually, but I guess an error is better.

let signal = content_process_shutdown_port.recv();
// When the script-thread drops the sender,
// we expect to receive an Err(_).
assert!(signal.is_err());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about who sends on this channel, since the only uses of send(()) appear to have been deleted. Are we using a channel just for its Drop implementation?

Copy link
Member Author

@gterzian gterzian Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, previously there was an explicit sending of a message when the script-thread exits, which I can bring back if you think that's clearer. Or we can effectively wait until the channel drops, and assert it is indeed the Err that would be received in such a case.

I think we can count on the channel not sending any spurious errors.

Copy link
Member Author

@gterzian gterzian Aug 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think you're right it's better to send an explicit message, since the drop could also be the result of an unexpected shutdown of the script-thread, while a message will almost always mean there was a graceful shutdown...

@@ -744,6 +744,7 @@ impl ScriptThreadFactory for ScriptThread {
thread_state::initialize(ThreadState::SCRIPT);
PipelineNamespace::install(state.pipeline_namespace_id);
TopLevelBrowsingContextId::install(state.top_level_browsing_context_id);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we need a new blank line :)

@gterzian gterzian force-pushed the cleanup_content_process_shutdown_ack branch 2 times, most recently from afc6480 to 4cd2730 Compare August 15, 2019 19:47
@gterzian
Copy link
Member Author

Ok, comments addressed @asajeffrey

Copy link
Member

@asajeffrey asajeffrey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, a question, but otherwise LGTM.

@@ -545,6 +530,7 @@ impl UnprivilegedPipelineContent {
self.script_chan.clone(),
self.load_data.url.clone(),
);
let (content_process_shutdown_chan, content_process_shutdown_port) = unbounded();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be unbounded or a one-shot channel?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of crossbeam having a dedicated one-shot variant.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant bounded(1).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for what reason?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible space efficiency, but it probably doesn't matter that much.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you mean, counterintuitively, the unbounded variant appears to require less bookkeeping than the bounded variant.

@asajeffrey
Copy link
Member

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 4cd2730 has been approved by asajeffrey

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 17, 2019
@bors-servo
Copy link
Contributor

⌛ Testing commit 4cd2730 with merge e0267e8...

bors-servo pushed a commit that referenced this pull request Aug 17, 2019
… r=asajeffrey

Restructure content process shutdown ack with threaded sender

Recycling some work from #23909

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

💔 Test failed - status-taskcluster

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 17, 2019
@gterzian gterzian force-pushed the cleanup_content_process_shutdown_ack branch from 4cd2730 to 8482d2e Compare August 17, 2019 14:03
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Aug 17, 2019
@gterzian
Copy link
Member Author

@asajeffrey Ok that was layout_2020 that required updating, done...

@asajeffrey
Copy link
Member

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 8482d2e has been approved by asajeffrey

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Aug 17, 2019
@bors-servo
Copy link
Contributor

⌛ Testing commit 8482d2e with merge 0ff5dc5...

bors-servo pushed a commit that referenced this pull request Aug 17, 2019
… r=asajeffrey

Restructure content process shutdown ack with threaded sender

Recycling some work from #23909

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

💔 Test failed - status-taskcluster

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 17, 2019
@gterzian
Copy link
Member Author

@bors-servo retry

seems like a taskcluster error: TASK FAILURE during artifact upload: file-missing-on-worker: Could not read file '/Users/worker/tasks/task_1566064170/repo/intermittents.log'

@bors-servo
Copy link
Contributor

💣 Failed to start rebuilding: Unknown error

@bors-servo
Copy link
Contributor

⌛ Testing commit 8482d2e with merge a8ae0e5...

bors-servo pushed a commit that referenced this pull request Aug 17, 2019
… r=asajeffrey

Restructure content process shutdown ack with threaded sender

Recycling some work from #23909

<!-- 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 #___ (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/23972)
<!-- Reviewable:end -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Aug 17, 2019
@bors-servo
Copy link
Contributor

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: asajeffrey
Pushing a8ae0e5 to master...

@bors-servo bors-servo merged commit 8482d2e into servo:master Aug 17, 2019
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 17, 2019
@gterzian gterzian deleted the cleanup_content_process_shutdown_ack branch August 18, 2019 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants