Skip to content

Non-blocking network IO - #28639

Merged
bors-servo merged 1 commit into
servo:masterfrom
negator:negator/async
Jan 1, 2022
Merged

bors-servo merged 1 commit into
servo:masterfrom
negator:negator/async

Conversation

@negator

@negator negator commented Dec 6, 2021 •

Copy link
Copy Markdown
Contributor

The current networking strategy uses a fixed sized thread pool to perform blocking requests on a per call basis. This is inefficient, but can be easily improved by utilizing the existing tokio runtime instead to submit async networking tasks to its executor. However, since servo is currently using an outdated version of the hyper http library (0.12) we must use the tokio_compat and futures_compat libraries to integrate with the older version of Future used in hyper.

NOTE: This PR is just proof of concept at the moment. In addition to test failures, it appears that large javascript downloads are silently failing to stream entire payloads, and occasionally getting cutoff.

Tests are passing.


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

@highfive

highfive commented Dec 6, 2021

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/Cargo.toml, components/net/fetch/methods.rs, components/net/resource_thread.rs, components/net/http_loader.rs, components/net_traits/response.rs and 1 more

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Dec 6, 2021
@highfive

highfive commented Dec 6, 2021

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • These commits modify net code, but no tests are modified. Please consider adding a test!

@negator
negator force-pushed the negator/async branch 2 times, most recently from 3bbb8d8 to cf9b2e1 Compare December 7, 2021 04:57
@negator
negator force-pushed the negator/async branch 5 times, most recently from bb1e867 to 5dd346e Compare December 18, 2021 02:51
Comment thread components/net_traits/request.rs Resolved
@negator
negator force-pushed the negator/async branch 2 times, most recently from 8a85c2f to 0686cba Compare December 18, 2021 19:44
@negator
negator marked this pull request as ready for review December 18, 2021 22:09
@jdm

jdm commented Dec 18, 2021

Copy link
Copy Markdown
Member

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 19da624 with merge 1652782...

bors-servo added a commit that referenced this pull request Dec 18, 2021
Non-blocking network IO

The current networking strategy uses a fixed sized thread pool to perform blocking requests on a per call basis. This is inefficient, but easily improved by utilizing the existing tokio runtime instead to submit async networking tasks to its executor. However, since servo is currently using an outdated version of the `hyper` http library (`0.12`) we must use the [`tokio_compat`](https://github.com/tokio-rs/tokio-compat) and [`futures_compat`](https://docs.rs/futures/0.3.1/futures/compat/index.html) libraries to integrate with the older version of [`Future` used in `hyper`](https://docs.rs/hyper/0.12.1/hyper/rt/trait.Future.html).

~**NOTE**: This PR is just proof of concept at the moment. In addition to test failures, it appears that large javascript downloads are silently failing to stream entire payloads, and occasionally getting cutoff.~

Tests are passing.

---
<!-- 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 [#22813](#22813) (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. -->
Comment thread components/net/fetch/methods.rs Resolved
@jdm

jdm commented Dec 19, 2021

Copy link
Copy Markdown
Member

These changes appear to cause a bunch of new timeouts in tests. I'll run them again to see if it's consistent or indicative or a more general problem that affects different tests intermittently.

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 2805de5 with merge 023a409...

bors-servo added a commit that referenced this pull request Dec 19, 2021
Non-blocking network IO

The current networking strategy uses a fixed sized thread pool to perform blocking requests on a per call basis. This is inefficient, but easily improved by utilizing the existing tokio runtime instead to submit async networking tasks to its executor. However, since servo is currently using an outdated version of the `hyper` http library (`0.12`) we must use the [`tokio_compat`](https://github.com/tokio-rs/tokio-compat) and [`futures_compat`](https://docs.rs/futures/0.3.1/futures/compat/index.html) libraries to integrate with the older version of [`Future` used in `hyper`](https://docs.rs/hyper/0.12.1/hyper/rt/trait.Future.html).

~**NOTE**: This PR is just proof of concept at the moment. In addition to test failures, it appears that large javascript downloads are silently failing to stream entire payloads, and occasionally getting cutoff.~

Tests are passing.

---
<!-- 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 [#22813](#22813) (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. -->
@negator

negator commented Dec 19, 2021

Copy link
Copy Markdown
Contributor Author

Guessing there was a deadlock introduced with the mutexes.

@jdm

jdm commented Dec 19, 2021

Copy link
Copy Markdown
Member

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 1830cc8 with merge bd6c039...

bors-servo added a commit that referenced this pull request Dec 19, 2021
Non-blocking network IO

The current networking strategy uses a fixed sized thread pool to perform blocking requests on a per call basis. This is inefficient, but easily improved by utilizing the existing tokio runtime instead to submit async networking tasks to its executor. However, since servo is currently using an outdated version of the `hyper` http library (`0.12`) we must use the [`tokio_compat`](https://github.com/tokio-rs/tokio-compat) and [`futures_compat`](https://docs.rs/futures/0.3.1/futures/compat/index.html) libraries to integrate with the older version of [`Future` used in `hyper`](https://docs.rs/hyper/0.12.1/hyper/rt/trait.Future.html).

~**NOTE**: This PR is just proof of concept at the moment. In addition to test failures, it appears that large javascript downloads are silently failing to stream entire payloads, and occasionally getting cutoff.~

Tests are passing.

---
<!-- 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 [#22813](#22813) (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. -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - checks-github

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Dec 19, 2021
@jdm

jdm commented Dec 19, 2021

Copy link
Copy Markdown
Member
  ▶ TIMEOUT [expected OK] b'/eventsource/event-data.html'
  │ 
  └ error: XDG_RUNTIME_DIR not set in the environment.

  ▶ Unexpected subtest result in /eventsource/event-data.html:
  │ TIMEOUT [expected PASS] b'EventSource: lines and data parsing'
  └   → Test timed out

1 unexpected results that are NOT known-intermittents:
  ▶ TIMEOUT [expected OK] b'/eventsource/event-data.html'
  │ 
  └ error: XDG_RUNTIME_DIR not set in the environment.

  ▶ Unexpected subtest result in /eventsource/event-data.html:
  │ TIMEOUT [expected PASS] b'EventSource: lines and data parsing'
  └   → Test timed out

  ▶ TIMEOUT [expected OK] b'/fetch/range/general.window.html'
  │ 
  └ error: XDG_RUNTIME_DIR not set in the environment.

  ▶ Unexpected subtest result in /fetch/range/general.window.html:
  │ TIMEOUT [expected FAIL] b'Fetch with range header will be sent with Accept-Encoding: identity'
  └   → Test timed out

Time to see if that's a stable set of timeouts.

@jdm

jdm commented Dec 19, 2021

Copy link
Copy Markdown
Member

@bors-servo retry

@jdm

jdm commented Dec 22, 2021

Copy link
Copy Markdown
Member

The tidy failures will be fixed by #28649.

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - checks-github

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Dec 22, 2021
@jdm

jdm commented Dec 22, 2021

Copy link
Copy Markdown
Member

Hmm, there's a huge volume of new timeouts in tests. I suspect something about a56a349 isn't working right.

@negator

negator commented Dec 22, 2021

Copy link
Copy Markdown
Contributor Author

Looks like it's file download timeouts.

I think the issue is related to: #28639 (comment)

thread_pool is a weak reference. Removing it as a field in CoreResourceManager probably deallocated it before it could be used in Filemanager.

@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Dec 22, 2021
@jdm

jdm commented Dec 22, 2021

Copy link
Copy Markdown
Member

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 587fda4 with merge 7241b29...

bors-servo added a commit that referenced this pull request Dec 22, 2021
Non-blocking network IO

The current networking strategy uses a fixed sized thread pool to perform blocking requests on a per call basis. This is inefficient, but can be ~easily~ improved by utilizing the existing tokio runtime instead to submit async networking tasks to its executor. However, since servo is currently using an outdated version of the `hyper` http library (`0.12`) we must use the [`tokio_compat`](https://github.com/tokio-rs/tokio-compat) and [`futures_compat`](https://docs.rs/futures/0.3.1/futures/compat/index.html) libraries to integrate with the older version of [`Future` used in `hyper`](https://docs.rs/hyper/0.12.1/hyper/rt/trait.Future.html).

~**NOTE**: This PR is just proof of concept at the moment. In addition to test failures, it appears that large javascript downloads are silently failing to stream entire payloads, and occasionally getting cutoff.~

Tests are passing.

---
<!-- 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 [#22813](#22813) (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. -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - checks-github

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Dec 23, 2021
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Dec 23, 2021
@jdm

jdm commented Dec 23, 2021

Copy link
Copy Markdown
Member

@bors-servo try

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit 43ef692 with merge a627c9e...

bors-servo added a commit that referenced this pull request Dec 23, 2021
Non-blocking network IO

The current networking strategy uses a fixed sized thread pool to perform blocking requests on a per call basis. This is inefficient, but can be ~easily~ improved by utilizing the existing tokio runtime instead to submit async networking tasks to its executor. However, since servo is currently using an outdated version of the `hyper` http library (`0.12`) we must use the [`tokio_compat`](https://github.com/tokio-rs/tokio-compat) and [`futures_compat`](https://docs.rs/futures/0.3.1/futures/compat/index.html) libraries to integrate with the older version of [`Future` used in `hyper`](https://docs.rs/hyper/0.12.1/hyper/rt/trait.Future.html).

~**NOTE**: This PR is just proof of concept at the moment. In addition to test failures, it appears that large javascript downloads are silently failing to stream entire payloads, and occasionally getting cutoff.~

Tests are passing.

---
<!-- 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 [#22813](#22813) (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. -->
@negator

negator commented Dec 23, 2021

Copy link
Copy Markdown
Contributor Author

@jdm Can we ensure this gets squash merged?

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-github, status-taskcluster
State: approved= try=True

@jdm

jdm commented Dec 23, 2021

Copy link
Copy Markdown
Member

Homu only supports using a merge commit, so you will need to do the squash yourself before this is merged.

@jdm

jdm commented Jan 1, 2022

Copy link
Copy Markdown
Member

@bors-servo r+
Thank you for digging into this!

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 903e0cd has been approved by jdm

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 903e0cd with merge b06eb38...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-github, status-taskcluster
Approved by: jdm
Pushing b06eb38 to master...

@bors-servo
bors-servo merged commit b06eb38 into servo:master Jan 1, 2022
@negator
negator deleted the negator/async branch January 1, 2022 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants