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

Spinquic to use operation priority #4351

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/core/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@ MsQuicStreamStart(
QUIC_STATUS Status;
QUIC_STREAM* Stream;
QUIC_CONNECTION* Connection;
BOOLEAN IsPriority = !!(Flags & QUIC_STREAM_START_FLAG_PRIORITY_WORK);
Flags &= ~QUIC_STREAM_START_FLAG_PRIORITY_WORK;
Copy link
Member

Choose a reason for hiding this comment

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

Why are all these changes necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found this is written for other api (StreamSend, SetParam etc.), so I added. Originally to check whether this fix stall issue


QuicTraceEvent(
ApiEnter,
Expand Down Expand Up @@ -853,7 +855,7 @@ MsQuicStreamStart(
//
// Queue the operation but don't wait for the completion.
//
if (Flags & QUIC_STREAM_START_FLAG_PRIORITY_WORK) {
if (IsPriority) {
QuicConnQueuePriorityOper(Connection, Oper);
} else {
QuicConnQueueOper(Connection, Oper);
Expand Down Expand Up @@ -1009,6 +1011,7 @@ MsQuicStreamSend(
QUIC_SEND_REQUEST* SendRequest;
BOOLEAN QueueOper = TRUE;
const BOOLEAN IsPriority = !!(Flags & QUIC_SEND_FLAG_PRIORITY_WORK);
Flags &= ~QUIC_SEND_FLAG_PRIORITY_WORK;
BOOLEAN SendInline;
QUIC_OPERATION* Oper;

Expand Down
1 change: 1 addition & 0 deletions src/core/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ QuicDatagramQueueSend(
QUIC_STATUS Status;
BOOLEAN QueueOper = TRUE;
const BOOLEAN IsPriority = !!(SendRequest->Flags & QUIC_SEND_FLAG_PRIORITY_WORK);
SendRequest->Flags &= ~QUIC_SEND_FLAG_PRIORITY_WORK;
QUIC_CONNECTION* Connection = QuicDatagramGetConnection(Datagram);

CxPlatDispatchLockAcquire(&Datagram->ApiQueueLock);
Expand Down
20 changes: 17 additions & 3 deletions src/tools/spin/spinquic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ struct SetParamHelper {
void SetUint64(uint32_t _Type, uint64_t Value) {
Type = _Type; Param.u64 = Value; Size = sizeof(Value);
}
void SetPriority() {
Type |= QUIC_PARAM_HIGH_PRIORITY;
}
void Apply(HQUIC Handle) {
if (Type != -1) {
MsQuic.SetParam(Handle, Type, Size, IsPtr ? Param.ptr : &Param);
Expand Down Expand Up @@ -828,6 +831,10 @@ void SpinQuicSetRandomConnectionParam(HQUIC Connection, uint16_t ThreadID)
break;
}

if (GetRandom(2)) {
Helper.SetPriority();
}

Helper.Apply(Connection);
}

Expand All @@ -853,6 +860,10 @@ void SpinQuicSetRandomStreamParam(HQUIC Stream, uint16_t ThreadID)
break;
}

if (GetRandom(2)) {
Helper.SetPriority();
}

Helper.Apply(Stream);
}

Expand All @@ -879,7 +890,10 @@ void SpinQuicGetRandomParam(HQUIC Handle, uint16_t ThreadID)
uint32_t Level = (uint32_t)GetRandom(ARRAYSIZE(ParamCounts));
uint32_t Param = (uint32_t)GetRandom(((ParamCounts[Level] & 0xFFFFFFF)) + 1);
uint32_t Combined = ((Level+1) << 28) + Param;
Combined &= ~QUIC_PARAM_HIGH_PRIORITY; // TODO: enable high priority GetParam
Combined &= ~QUIC_PARAM_HIGH_PRIORITY;
if (GetRandom(2)) {
Combined |= QUIC_PARAM_HIGH_PRIORITY;
}

uint8_t OutBuffer[200];
uint32_t OutBufferLength = (uint32_t)GetRandom(sizeof(OutBuffer) + 1);
Expand Down Expand Up @@ -1010,7 +1024,7 @@ void Spin(Gbs& Gb, LockableVector<HQUIC>& Connections, std::vector<HQUIC>* Liste
Buffer->Buffer = Gb.SendBuffer + StreamCtx->SendOffset;
Buffer->Length = Length;
if (QUIC_SUCCEEDED(
MsQuic.StreamSend(Stream, Buffer, 1, (QUIC_SEND_FLAGS)GetRandom(16), Buffer))) {
MsQuic.StreamSend(Stream, Buffer, 1, (QUIC_SEND_FLAGS)GetRandom(128), Buffer))) {
StreamCtx->SendOffset = (uint8_t)(StreamCtx->SendOffset + Length);
} else {
delete Buffer;
Expand Down Expand Up @@ -1145,7 +1159,7 @@ void Spin(Gbs& Gb, LockableVector<HQUIC>& Connections, std::vector<HQUIC>* Liste
if (Buffer) {
Buffer->Buffer = Gb.SendBuffer;
Buffer->Length = MaxBufferSizes[GetRandom(BufferCount)];
if (QUIC_FAILED(MsQuic.DatagramSend(Connection, Buffer, 1, (QUIC_SEND_FLAGS)GetRandom(8), Buffer))) {
if (QUIC_FAILED(MsQuic.DatagramSend(Connection, Buffer, 1, (QUIC_SEND_FLAGS)GetRandom(128), Buffer))) {
delete Buffer;
}
}
Expand Down
Loading