-
Notifications
You must be signed in to change notification settings - Fork 157
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
ProtocolReader.ReadAsync doesn't advance if read is successful #70
Comments
nm; I think I get it now - the |
FYI, initial results - noting that SE.Redis does a lot more and is optimized for different usage to this: ExecuteBedrock: time for 1000 ops: 76ms
ExecuteStackExchagneRedis: time for 1000 ops: 92ms |
also: got it kinda sorta working in a BDN project, but now I'm seeing: ---> System.InvalidOperationException: End position was not reached during enumeration.
at System.ThrowHelper.ThrowInvalidOperationException_EndPositionNotReached()
at System.Buffers.SequenceReader`1.IsNextSlow(ReadOnlySpan`1 next, Boolean advancePast)
at System.Buffers.SequenceReader`1.TryReadTo(ReadOnlySequence`1& sequence, ReadOnlySpan`1 delimiter, Boolean advancePastDelimiter)
at System.Buffers.SequenceReaderExtensions.TryReadTo[T](SequenceReader`1& sequenceReader, ReadOnlySpan`1& span, ReadOnlySpan`1 delimiter, Boolean advancePastDelimiter) in C:\Code\BedrockRespProtocol\src\BedrockRespProtocol\Lifted\SequenceReaderExtensions.cs:line 7 I'm assuming that is the bug @Drawaes was telling me about? |
Yes the very same bug.... Might need to work around it ....let me have a look tonight |
On the API design: I think I'm in favor of the explicit |
@Drawaes I worked around it by changing to the super-sophisticated: if (sequenceReader.TryReadTo(out ReadOnlySequence<byte> payloadPlusPrefix, (byte)'\r')
&& sequenceReader.TryRead(out var n) && n == '\n') which correctly locates my CR/LF pairs without falling in a mound. Allocations are higher than the competing code, note - I think this is probably TPL overheads:
|
initial allocations count based on 1000 operations: Name Total (Allocations) Self (Allocations) Total Size (Bytes) Self Size (Bytes)
going to see what happens if I use |
with Name Total (Allocations) Self (Allocations) Total Size (Bytes) Self Size (Bytes)
The The AsyncTaskMethodBuilder The |
most of the allocs should just evaporate if we can justify turning on the task amortizer bits; the ones that remain are the |
@mgravell found the same and created JanEggers@4ed38b6 should i create a pr or are the more buildin solutions? what is Task amortizer bits can you post a link i would like to try that with my mqtt bits. |
The fix is these allocations is to do #19. I haven't done it yet, it's mostly copy pasta from Kestrel. |
@JanEggers that custom scheduler looks pretty hairy re concurrency; I wonder if it would be better to simply test the |
I guess voodoo is the best option |
@davidfowl the state machine evaporates if we dotnet/runtime#13633 |
The
AdvanceTo
is only invoked when read fails; most protocols will involve multiple messages, but the second call toReadAsync
reliably fails with:Repro is here
The text was updated successfully, but these errors were encountered: