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

quic: additional quic refactors/cleanups #34160

Closed
wants to merge 11 commits into from

Conversation

jasnell
Copy link
Member

@jasnell jasnell commented Jul 1, 2020

This is ready for review...

  • quic: continued refactoring for quic_stream/quic_session
  • quic: refactor native object flags for better readability
  • quic: additional cleanups on the c++ side

The first three commits are general improvements to improve maintainability, readability, and quality of the c++ code...

  • quic: refactor QuicSession close/destroy flow

This commit refactors the QuicSession close/destroy flow to (a) make it more correct and (b) make it far easier to reason about.

  • quic: refactor QuicSession shared state to use AliasedStruct

The shared state between the C++ side and the JavaScript side was using an AliasedArray where everything was uint64_t, which is wasteful given that most of the state fields are simple booleans. Using an AliasedStruct allows it to be more compact but does make reading it a bit more complicated on the JS side. Overall, this should be easier to maintain.

  • quic: remove onSessionDestroy callback

The onSessionDestroy callback was calling out to JavaScript during the QuicSession C++ object deconstruction, which could happen during garbage collection, so that's a no-no. This eliminates that callback.

  • quic: refactor qlog handling

What it says on the tin.

  • quic: fixup lint issues

Also self-explanatory

  • quic: cleanup timers if they haven't been already

When the QuicSession is GC'd without a proper destroy, the timers weren't being freed properly. Make
sure they are stopped.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@jasnell jasnell added the quic Issues and PRs related to the QUIC implementation / HTTP/3. label Jul 1, 2020
@jasnell jasnell force-pushed the quic-cleanups-3 branch 2 times, most recently from 092153e to 244b88e Compare July 1, 2020 23:59
@zbot473

This comment has been minimized.

@jasnell jasnell force-pushed the quic-cleanups-3 branch 3 times, most recently from 0071050 to bab96a7 Compare July 2, 2020 23:11
@jasnell jasnell marked this pull request as ready for review July 2, 2020 23:11
@jasnell jasnell requested a review from a team July 2, 2020 23:11
@jasnell

This comment has been minimized.

@zbot473

This comment has been minimized.

@jasnell

This comment has been minimized.

@jasnell
Copy link
Member Author

jasnell commented Jul 2, 2020

@zbot473

This comment has been minimized.

@gengjiawen

This comment has been minimized.

@zbot473

This comment has been minimized.

@zbot473

This comment has been minimized.

@jasnell

This comment has been minimized.

@jasnell
Copy link
Member Author

jasnell commented Jul 3, 2020

Updated QUIC CI: https://ci.nodejs.org/job/node-test-commit/39444/

src/quic/node_quic_session.h Outdated Show resolved Hide resolved
src/quic/node_quic_session.cc Outdated Show resolved Hide resolved
src/quic/node_quic_session.h Outdated Show resolved Hide resolved
The QuicSession can be destroyed during garbage collection and
the onSessionDestroy callback was happening in the destructor.
Because of the timing of qlog events emitted by ngtcp2, it
becomes difficult to handle those as events on the QuicSession
object because the final qlog entry is not emitted until the
ngtcp2_conn is freed, which can occur when the object is being
garbage collected (meaning, we a: can't call out to javascript
and b: don't have an object we can use to emit the event).

This refactors it into a QLogStream object that allows the
qlog data to be piped out using a separate Readable stream.
@jasnell
Copy link
Member Author

jasnell commented Jul 3, 2020

@addaleax... updated, PTAL

@jasnell jasnell requested a review from addaleax July 3, 2020 17:53
@jasnell
Copy link
Member Author

jasnell commented Jul 3, 2020

Updated QUIC CI: https://ci.nodejs.org/job/node-test-commit/39450/

@nodejs-github-bot
Copy link
Collaborator

@zbot473
Copy link

zbot473 commented Jul 3, 2020

What's the difference between a vanilla QUIC implementation with the proper ALPN and QuicTransport?

I know this probably isn't the best place to talk about this, but I am going to hold off on making a new issue until this PR is merged.

jasnell added a commit that referenced this pull request Jul 5, 2020
jasnell added a commit that referenced this pull request Jul 5, 2020
Use is_* and set_* pattern for native object flags to improve
readability in the code.

PR-URL: #34160
Reviewed-By: Anna Henningsen <[email protected]>
jasnell added a commit that referenced this pull request Jul 5, 2020
jasnell added a commit that referenced this pull request Jul 5, 2020
jasnell added a commit that referenced this pull request Jul 5, 2020
jasnell added a commit that referenced this pull request Jul 5, 2020
The QuicSession can be destroyed during garbage collection and
the onSessionDestroy callback was happening in the destructor.

PR-URL: #34160
Reviewed-By: Anna Henningsen <[email protected]>
jasnell added a commit that referenced this pull request Jul 5, 2020
Because of the timing of qlog events emitted by ngtcp2, it
becomes difficult to handle those as events on the QuicSession
object because the final qlog entry is not emitted until the
ngtcp2_conn is freed, which can occur when the object is being
garbage collected (meaning, we a: can't call out to javascript
and b: don't have an object we can use to emit the event).

This refactors it into a QLogStream object that allows the
qlog data to be piped out using a separate Readable stream.

PR-URL: #34160
Reviewed-By: Anna Henningsen <[email protected]>
jasnell added a commit that referenced this pull request Jul 5, 2020
PR-URL: #34160
Reviewed-By: Anna Henningsen <[email protected]>
jasnell added a commit that referenced this pull request Jul 5, 2020
jasnell added a commit that referenced this pull request Jul 5, 2020
@jasnell
Copy link
Member Author

jasnell commented Jul 5, 2020

Landed in 56dbe46...1b1e985

@jasnell jasnell closed this Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
quic Issues and PRs related to the QUIC implementation / HTTP/3.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants