Skip to content

HTTP/3: ValueTask pooling - #42760

Merged
JamesNK merged 3 commits into
mainfrom
jamesnk/valuetaskpooling
Aug 1, 2022
Merged

JamesNK merged 3 commits into
mainfrom
jamesnk/valuetaskpooling

Conversation

@JamesNK

@JamesNK JamesNK commented Jul 17, 2022

Copy link
Copy Markdown
Member

Pool some async methods on QuicStreamContext.

@adityamandaleeka

Copy link
Copy Markdown
Member

Do we have any data indicating that pooling here is beneficial?

@JamesNK

JamesNK commented Jul 26, 2022

Copy link
Copy Markdown
Member Author

I'll benchmark before/after once other PRs are merged and profile performance again. I doubt this change alone will have any material difference.

@JamesNK

JamesNK commented Jul 31, 2022

Copy link
Copy Markdown
Member Author

Before:
image

After:
image

@JamesNK
JamesNK force-pushed the jamesnk/valuetaskpooling branch from 91df2ac to d462577 Compare July 31, 2022 12:32
// which is why we listen for a notification that the write-side of the stream is done.
// An exception can be thrown from the stream on client abort which will be captured and then wake up the output read.
_ = WaitForWritesCompleted();
var waitForWritesClosedTask = WaitForWritesClosedAsync();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Bad merge? This undoes #42683

@JamesNK JamesNK Aug 1, 2022 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's intentional. I noticed some failures when benchmarking after that change.

Also, pooling the task requires awaiting it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

_ = for Tasks and ValueTasks is almost always bad. I've seen very few counterexamples. Although it's often done for expedience when properly handling the task would be extremely difficult, it would still be better to await everything if it were easily doable.

Even if you do things like log all uncaught exceptions to make discarding tasks better, how do you know the logger is still alive sending your logs to wherever they need to go if you aren't awaiting all your tasks and properly delaying shutdown?

@JamesNK
JamesNK merged commit acff643 into main Aug 1, 2022
@JamesNK
JamesNK deleted the jamesnk/valuetaskpooling branch August 1, 2022 22:44
@ghost ghost added this to the 7.0-rc1 milestone Aug 1, 2022
@davidfowl davidfowl added the Perf label Aug 26, 2022
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Perf

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants