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

feat: use DuplexStream instead of UnixStream to communicate with workers #320

Merged
merged 4 commits into from
Apr 19, 2024

Conversation

nyannyacha
Copy link
Collaborator

@nyannyacha nyannyacha commented Apr 16, 2024

What kind of change does this PR introduce?

Refactor

Description

This PR changes the stream type used to communicate between workers to DuplexStream instead of UnixStream to improve request throughput.

It was tested on a local machine, so it's imprecise, but it showed an improvement of about 10% in request throughput per second.

List of arguments to be created due to the introduction of this PR

  • --tcp-nodelay flag disables Nagle's algorithm. (Default is true)

Figure1. UnixStream, Debug
unixstream_debug

Figure2. DuplexStream, Debug
duplexstream_debug

Figure3. UnixStream, Release
unixstream_release

Figure4. DuplexStream, Release
duplexstream_release

Figure5. DuplexStream, Debug (examples/chunked-text, TCP_NODELAY OFF)
duplex-chunked-debug

Figure6. DuplexStream, Debug (examples/chunked-text, TCP_NODELAY ON)
스크린샷 2024-04-17 오후 1 32 45

@nyannyacha nyannyacha marked this pull request as ready for review April 18, 2024 21:02
@nyannyacha
Copy link
Collaborator Author

Note: Please keep a close eye on stage infra to ensure that there are no runtime issues after merging this PR. (But I don't expect any issues.)

@laktek
Copy link
Contributor

laktek commented Apr 19, 2024

@nyannyacha Can you prefix this PR as a feat (so it will create a minor release)

@nyannyacha nyannyacha changed the title perf: use DuplexStream instead of UnixStream to communicate with workers feat: use DuplexStream instead of UnixStream to communicate with workers Apr 19, 2024
crates/sb_core/http_start.rs Outdated Show resolved Hide resolved
@nyannyacha nyannyacha merged commit 4e53e2a into supabase:main Apr 19, 2024
3 checks passed
@nyannyacha nyannyacha deleted the perf-req branch April 19, 2024 02:08
Copy link

🎉 This PR is included in version 1.44.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

nyannyacha added a commit to nyannyacha/edge-runtime that referenced this pull request Apr 22, 2024
…te with workers (supabase#320)"

This reverts commit 4e53e2a.

# Conflicts:
#	crates/base/src/server.rs
#	crates/cli/src/main.rs
nyannyacha added a commit to nyannyacha/edge-runtime that referenced this pull request Apr 22, 2024
…te with workers (supabase#320)"

This reverts commit 4e53e2a.

# Conflicts:
#	crates/base/src/server.rs
#	crates/cli/src/main.rs
nyannyacha added a commit that referenced this pull request Apr 22, 2024
…municate with workers (#320)" (#326)

This reverts commit 4e53e2a.

# Conflicts:
#	crates/base/src/server.rs
#	crates/cli/src/main.rs
nyannyacha added a commit to nyannyacha/edge-runtime that referenced this pull request Apr 25, 2024
nyannyacha added a commit to nyannyacha/edge-runtime that referenced this pull request May 2, 2024
nyannyacha added a commit to nyannyacha/edge-runtime that referenced this pull request May 2, 2024
nyannyacha added a commit to nyannyacha/edge-runtime that referenced this pull request May 6, 2024
nyannyacha added a commit that referenced this pull request May 7, 2024
* feat: reintroduce `DuplexStream`

See #320

* stamp: add an example for chunked transfer encoding

* fix: defer pipe closure timing

* stamp: polishing

* fix: original request body should be able to abort when a request to the user worker has been cancelled

* stamp: adjust edge runtime arguments of `scripts/run.sh`

* stamp(k6): add a scenario for upload failure due to exceeding max size

* refactor: simplify the expression of connection lifetime using `CancellationToken`

* fix: update feature flag for `base` crate

* stamp: polishing

* chore: update `Dockerfile`

* chore: update file update examples

* chore(base): update dependencies

* chore: update `Cargo.lock`

* stamp: update deno file update example

* stamp: polishing

* stamp: add an integration test for request failure during multipart uploading

* stamp: don’t expose `Interrupted` error to outside

* chore(sb_workers): update dependencies

* chore: update `Cargo.lock`

* fix: cleanup request body unconditionally

* stamp: update oak file update example

* fix: propagate user worker side error properly

* stamp: cleanup tests codes and add more tests for file uploads

* fix: prevent stack overflow when dropping `Stream2`

* stamp: disambiguate local variable naming

* stamp: polishing

* stamp(k6): update a scenario

* stamp: update an oak file upload example

* stamp: update main service example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants