-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Use one SequenceReader+Rewind rather than 2 SequenceReaders #8076
Conversation
Rewind is expensive; trying something else |
@benaadams Btw, rebase on Edit: I think re-running will get the changes, so I'm triggering helix again. |
/azp run AspNetCore-helix-test |
Azure Pipelines successfully started running 1 pipeline(s). |
@benaadams This change: aspnet/KestrelHttpServer#3068 has a revamp of this code which in micro benchmarks was much much faster. Do you have any interest in getting that back up / further refining it? It would be good for measuring the impact of other possible reader changes. |
@JeremyKuhne If I made the parser "safe"; what would @blowdart think of me 😱 Will take a look 😸 |
Bit of a rabbit hole, probably should be done as its own PR |
Sorry, I wasn't suggesting that it be done in this PR. It does, however, cross over this same method and make this change moot (I think). I'll get that one going again if you don't want to, just thought I'd point it out and offer it to you as you're much more focused on this right now than I am. :) Just let me know. |
Method | Mean | Error | StdDev | Op/s | Scaled |
--------------------- |---------:|---------:|---------:|------------:|-------:|
- PlaintextTechEmpower | 310.4 ns | 1.301 ns | 1.153 ns | 3,221,411.1 | 1.00 |
+ PlaintextTechEmpower | 271.8 ns | 2.267 ns | 2.121 ns | 3,679,437.9 | 1.00 |
- LiveAspNet | 526.9 ns | 2.322 ns | 1.939 ns | 1,897,874.1 | 1.70 |
+ LiveAspNet | 454.3 ns | 2.496 ns | 2.212 ns | 2,201,384.0 | 1.55 |
- Unicode | 687.7 ns | 3.629 ns | 3.217 ns | 1,454,153.2 | 2.22 |
+ Unicode | 614.2 ns | 3.414 ns | 3.193 ns | 1,628,024.1 | 2.09 | |
Helix Win10 error
|
Yep, that's https://github.com/aspnet/AspNetCore/issues/7366. Applying ye olde skip attribute ;P |
#8129 should unblock this |
Rebased |
Rebased |
Moving this to preview 6. FYI, this should not be merged until we've got confirmation that the branch is open for preview 6 changes. We've got a tight timeline for preview 5 and are starting to lock down now :). |
Rebased |
Rebased |
@davidfowl @Tratcher @jkotalik @halter73 Where do we stand (on our side) as far as merging this? Preview 6 is locking soon and we already punted this from preview 5 :). |
Rebased |
Rebased |
Rebased |
Ping @Tratcher @jkotalik @halter73 - we should get this reviewed instead of just making @benaadams rebase it down the road ;P |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks solid to me. I think we're ready to merge. @davidfowl do you agree?
} | ||
|
||
return result; | ||
bool TrimAndTakeMessageHeaders(in ReadOnlySequence<byte> buffer, bool trailers, out SequencePosition consumed, out SequencePosition examined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The redundancy of TakeMessageHeaders and TrimAndTakeMessageHeaders is one thing I don't love, but I understand doing this if necessary to optimize the fast path.
Thanks @benaadams |
SequenceReader is a very chunky struct; so taking a copy of it to rewind 2 chars in an uncommon case is expensive as it forces stack reservation and zeroing for the copy:
Also move the exception handling to the outer method, and clean up the loop
(Some PR changes highlighted by diff)
Zeroing in the common path to set it to
default(SequenceReader<byte>)
/cc @JeremyKuhne @davidfowl