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

http2: use session not socket timeout, tests #15188

Closed

Conversation

apapirovski
Copy link
Member

This fixes #15158. Two changes included:

  • there's no longer a default server socket timeout, it's now replaced by a default session timeout
  • _unrefActive was being called on the handler rather than the actual session

Marked as WIP as I think we need to investigate whether socket timeout is necessary anywhere and also because this needs a lot more tests, ideally.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

http2, test

@nodejs-github-bot nodejs-github-bot added the http2 Issues or PRs related to the http2 subsystem. label Sep 4, 2017
@apapirovski
Copy link
Member Author

Also something I just noticed, this earlier PR should probably be revisited in light of this #15106 — I'm not sure if all of it is relevant anymore?

@apapirovski apapirovski force-pushed the patch-http2-session-timeout branch 2 times, most recently from fec3fdd to d669eeb Compare September 5, 2017 19:44
@apapirovski apapirovski changed the title [WIP] http2: use session not socket timeout, tests http2: use session not socket timeout, tests Sep 5, 2017
@apapirovski
Copy link
Member Author

@jasnell, @mcollina this should be ready to review. Ideally we would have more tests around this behaviour but it does fix the bug and it does work in a way that makes sense.

@mcollina
Copy link
Member

mcollina commented Sep 6, 2017

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Can you please check if this affect performance anyhow?

Assuming it does not cause a regression.. LGTM

@apapirovski
Copy link
Member Author

Will test later today but I would be surprised if it doesn't affect performance at least a little bit. For one, _unrefActive was being called on something that wasn't a timer and two, the socket timeout was never _unrefActive either.

@mcollina
Copy link
Member

mcollina commented Sep 6, 2017

I think the failures on Mac OS X are unrelated.

Let us know about the performance impact.

@jasnell what do you think?

@apapirovski
Copy link
Member Author

Will need to figure out how to get h2load built on a Mac so this might take me a little while. Will update when I make it work.

@apapirovski
Copy link
Member Author

apapirovski commented Sep 6, 2017

@mcollina It's not too bad after all.

 http2/headers.js nheaders=0 n=1000        -1.62 %        *** 7.214983e-05
 http2/headers.js nheaders=10 n=1000       -1.29 %            6.246195e-02
 http2/headers.js nheaders=100 n=1000      -0.90 %            2.357148e-01
 http2/headers.js nheaders=1000 n=1000      0.70 %            4.645484e-01

Not too surprising that there's a tiny bit of a hit since before this PR the timeouts were completely bugged and weren't doing anything (basically no-op). Same benchmark with server.timeout = 0; yields this:

 http2/headers.js nheaders=0 n=1000         2.41 %            0.1543180
 http2/headers.js nheaders=10 n=1000        1.42 %            0.3769546
 http2/headers.js nheaders=100 n=1000       0.82 %            0.5944166
 http2/headers.js nheaders=1000 n=1000      0.19 %            0.9174064

Edit: This is after 40 runs on each node version btw.

debug('session timeout');
process.nextTick(() => {
// if destroyed or destryoing, do nothing
if (this.destroyed || this.destroying)
Copy link
Member

Choose a reason for hiding this comment

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

should be faster to use the kState references here instead of the getters

Copy link
Member Author

Choose a reason for hiding this comment

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

Posting an updated version shortly. Thanks for the review!

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

LGTM with green CI

@jasnell
Copy link
Member

jasnell commented Sep 7, 2017

There was too much red in the last CI run, trying again: https://ci.nodejs.org/job/node-test-commit/12214/

@jasnell
Copy link
Member

jasnell commented Sep 7, 2017

CI is definitely not green on this one: https://ci.nodejs.org/job/node-test-commit-linuxone/8427/nodes=rhel72-s390x/console

@apapirovski ... can you take a look?

btw, I really appreciate that you've jumped in on these. PR's from new contributors make me super happy :-)

@apapirovski
Copy link
Member Author

I think the test might be flaky because of the low timeout. Will look into it.

@apapirovski
Copy link
Member Author

apapirovski commented Sep 7, 2017

@jasnell can we run the CI again? I adjusted the timing to be less strict to match some of the other timeout tests. At 20ms the margin for error was too small.

@mcollina
Copy link
Member

mcollina commented Sep 7, 2017

@apapirovski
Copy link
Member Author

Worked this time. Nice! Thanks for the reviews @mcollina & @jasnell.

@mcollina
Copy link
Member

mcollina commented Sep 7, 2017

This does not land cleanly on master, can you please rebase and squash?

Change default timeout to be tracked on the session instead
of the socket, as nghttp2 manages the socket and we would
need to maintain two sets of timeouts for similar purpose.
Also fixes session setTimeout to work as it wasn't getting
_unrefActive correctly (was called on the handle).

Fixes: nodejs#15158
@apapirovski
Copy link
Member Author

All done.

@mcollina
Copy link
Member

mcollina commented Sep 7, 2017

Landed as 46133b5

@mcollina mcollina closed this Sep 7, 2017
mcollina pushed a commit that referenced this pull request Sep 7, 2017
Change default timeout to be tracked on the session instead
of the socket, as nghttp2 manages the socket and we would
need to maintain two sets of timeouts for similar purpose.
Also fixes session setTimeout to work as it wasn't getting
_unrefActive correctly (was called on the handle).

Fixes: #15158
PR-URL: #15188
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@apapirovski apapirovski deleted the patch-http2-session-timeout branch September 7, 2017 20:06
MylesBorins pushed a commit that referenced this pull request Sep 10, 2017
Change default timeout to be tracked on the session instead
of the socket, as nghttp2 manages the socket and we would
need to maintain two sets of timeouts for similar purpose.
Also fixes session setTimeout to work as it wasn't getting
_unrefActive correctly (was called on the handle).

Fixes: #15158
PR-URL: #15188
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Sep 10, 2017
MylesBorins pushed a commit that referenced this pull request Sep 11, 2017
Change default timeout to be tracked on the session instead
of the socket, as nghttp2 manages the socket and we would
need to maintain two sets of timeouts for similar purpose.
Also fixes session setTimeout to work as it wasn't getting
_unrefActive correctly (was called on the handle).

Fixes: #15158
PR-URL: #15188
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 12, 2017
Change default timeout to be tracked on the session instead
of the socket, as nghttp2 manages the socket and we would
need to maintain two sets of timeouts for similar purpose.
Also fixes session setTimeout to work as it wasn't getting
_unrefActive correctly (was called on the handle).

Fixes: #15158
PR-URL: #15188
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
addaleax pushed a commit to addaleax/node that referenced this pull request Sep 13, 2017
Change default timeout to be tracked on the session instead
of the socket, as nghttp2 manages the socket and we would
need to maintain two sets of timeouts for similar purpose.
Also fixes session setTimeout to work as it wasn't getting
_unrefActive correctly (was called on the handle).

Fixes: nodejs#15158
PR-URL: nodejs#15188
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

http2 session closing after 2 minutes, even if activity
5 participants