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

fix(ext/http): avoid lockup in graceful shutdown #21253

Merged
merged 1 commit into from Nov 23, 2023

Conversation

mmastrac
Copy link
Member

@mmastrac mmastrac commented Nov 18, 2023

Follow-up to #20822. cc @lrowe

The httpServerExplicitResourceManagement tests were randomly failing on CI because of a race.

The drain waker was missing wakeup events if the listeners shut down after the last HTTP response finished. If we lost the race (rare), the server Rc would be dropped and we wouldn't poll it again.

This replaces the drain waker system with a signalling Rc that always resolves when the refcount is about to become 1.

Fix verified by running serve tests in a loop:

for i in {0..100}; do cargo run --features=__http_tracing -- test
 -A --unstable '/Users/matt/Documents/github/deno/deno/cli/tests/unit/ser
ve_test.ts' --filter httpServerExplicitResourceManagement; done;

@lrowe
Copy link
Contributor

lrowe commented Nov 18, 2023

This looks a neat solution.

@mmastrac
Copy link
Member Author

Waiting to land this until I get the benchmark bot fixed.

@mmastrac
Copy link
Member Author

/bench http[minimal,realistic]

@denobot
Copy link
Collaborator

denobot commented Nov 21, 2023

http[minimal]

rps latency bytes relative
node 86,232 115.23 µs σ=37.24 732,431 kB -72.2%
bun 310,332 31.92 µs σ=14.07 1,523,437 kB best
deno 174,939 55.34 µs σ=14.38 1,435,546 kB -43.6%
deno-baseline 170,130 56.66 µs σ=14.82 1,396,484 kB -45.2%

http[realistic]

rps latency bytes relative
node 84,539 117.49 µs σ=36.41 908,203 kB -56.8%
bun 195,556 58.09 µs σ=125.29 1,826,171 kB best
deno 144,841 67.19 µs σ=22.64 1,533,203 kB -25.9%
deno-baseline 145,680 66.85 µs σ=19.73 1,542,968 kB -25.5%

start: Tue, 21 Nov 2023 19:49:53 GMT

id: 356a5167-f348-4c5a-9834-dabab554bbbc

server: d87cff58-fdac-4b3a-a35b-993f6d74ea98

@denoland denoland deleted a comment from denobot Nov 21, 2023
@mmastrac mmastrac enabled auto-merge (squash) November 21, 2023 20:23
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM

@mmastrac mmastrac merged commit 68a0877 into denoland:main Nov 23, 2023
14 checks passed
crowlKats pushed a commit that referenced this pull request Nov 24, 2023
Follow-up to #20822. cc @lrowe

The `httpServerExplicitResourceManagement` tests were randomly failing
on CI because of a race.

The `drain` waker was missing wakeup events if the listeners shut down
after the last HTTP response finished. If we lost the race (rare), the
server Rc would be dropped and we wouldn't poll it again.

This replaces the drain waker system with a signalling Rc that always
resolves when the refcount is about to become 1.

Fix verified by running serve tests in a loop:

```
for i in {0..100}; do cargo run --features=__http_tracing -- test
 -A --unstable '/Users/matt/Documents/github/deno/deno/cli/tests/unit/ser
ve_test.ts' --filter httpServerExplicitResourceManagement; done;
```

(cherry picked from commit 68a0877)
bartlomieju pushed a commit that referenced this pull request Nov 24, 2023
Follow-up to #20822. cc @lrowe 

The `httpServerExplicitResourceManagement` tests were randomly failing
on CI because of a race.

The `drain` waker was missing wakeup events if the listeners shut down
after the last HTTP response finished. If we lost the race (rare), the
server Rc would be dropped and we wouldn't poll it again.

This replaces the drain waker system with a signalling Rc that always
resolves when the refcount is about to become 1.

Fix verified by running serve tests in a loop:

```
for i in {0..100}; do cargo run --features=__http_tracing -- test
 -A --unstable '/Users/matt/Documents/github/deno/deno/cli/tests/unit/ser
ve_test.ts' --filter httpServerExplicitResourceManagement; done;
```
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

4 participants