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

Add "delay" and "delayType" options to secnetperf tool #4807

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

sm-msft
Copy link
Contributor

@sm-msft sm-msft commented Feb 12, 2025

This not quite the same as the feature request described in issue #1524, but it achieves some of the goals. The stream processing on the server side is already multithreaded and the use of exponential probability distribution to determine the delay for the current stream simulates variable processing time for a request on the server side.

We can introduce background thread processing as suggested in the issue description to simulate further processing delays on the server side to enable a richer simluation.

Description

Add the ability to introduce server-side delays into data streams in the secnetperf tool.

  • Default/fixed delay introduces specific microseconds of inline busy-wait delay when the stream is established
  • Variable delay introduces an exponetially distributed random busy-wait delay. This is capped at max(1millisecond, 4x given delay) of inline sleep.
  • Documentation/help text updated
  • Minor code reorganization

Testing

This change updates the test tool. Existing tests are all passing with this change.

Documentation

Documentation has been updated.

- Default/fixed delay introduces specific microseconds of inline busy-wait delay when the stream is established
- Variable delay introduces an exponetially distributed random busy-wait delay. This is capped at 1millisecond inline sleep.
- Documentation/help text updated
@sm-msft sm-msft assigned sm-msft and nibanks and unassigned sm-msft Feb 12, 2025
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.91%. Comparing base (7b2fbaf) to head (15a1b04).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4807      +/-   ##
==========================================
- Coverage   87.43%   86.91%   -0.53%     
==========================================
  Files          56       56              
  Lines       17634    17634              
==========================================
- Hits        15419    15326      -93     
- Misses       2215     2308      +93     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nibanks nibanks changed the title - Add "delay" and "delayType" options to secnetperf tool Add "delay" and "delayType" options to secnetperf tool Feb 12, 2025
…and sending responses from the server.

  - Based on the perflib TCP worker threadpool code
  - 1 worker thread per processor
  - Existing code (QUIC/TCP) queues background work on the current processor only when a server response is due.
  - The existing Quic/TCP connection/stream is assumed to be available till the background operation completes
  - DelayWork thread adds appropriate amount of delay and then sends the response back on the appropriate stream
*Minor code reorganization in PerfServer.h
*Addressed review comments from prior iteration
InterlockedFetchAndSetBoolean(&ExecutionContext.Ready);
ExecutionContext.NextTimeUs = UINT64_MAX;

uint16_t ThreadFlags = CXPLAT_THREAD_FLAG_SET_IDEAL_PROC;
Copy link
Member

Choose a reason for hiding this comment

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

Not really necessary to make a separate variable just for this.


uint16_t ThreadFlags = CXPLAT_THREAD_FLAG_SET_IDEAL_PROC;
//
// Not using the high priority flag for delay threads
Copy link
Member

Choose a reason for hiding this comment

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

Let's just remove this comment. Most things don't run at high priority, so saying this isn't using that is unnecessary IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is in contrast with other threadpools we use in this binary and we have to highlight it somehow..

Comment on lines +695 to +697
if (nullptr == Work) {
return false;
}
Copy link
Member

Choose a reason for hiding this comment

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

Since this is test/tool code, we generally assume allocation success. Let's remove this check, which simplifies the whole function (it can't fail then) as well as the callers.

Comment on lines +83 to +84
" -delay:<####>[unit] Delay, with an optional unit (def unit is us), to be introduced before the server responds to a request. (def:0)\n"
" -delayType:<fixed|variable> Optional delay type can be specified in conjunction with the 'delay' argument.\n"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
" -delay:<####>[unit] Delay, with an optional unit (def unit is us), to be introduced before the server responds to a request. (def:0)\n"
" -delayType:<fixed|variable> Optional delay type can be specified in conjunction with the 'delay' argument.\n"
" -delay:<####>[unit] Delay, with an optional unit (def unit is us), to be introduced before the server responds to a request. (def:0)\n"
" -delayType:<type> Optional delay type can be specified in conjunction with the 'delay' argument.\n"

We generally use this convention for parameters

@@ -29,6 +29,8 @@ ecn | `-ecn:<0,1>` | Enables sender-side ECN support.
exec | `-exec:<lowlat,maxtput,scavenger,realtime>` | The execution profile used for the application.
pollidle | `-pollidle:<time_us>` | The time, in microseconds, to poll while idle before sleeping (falling back to interrupt-driven IO).
stats | `-stats:<0,1>` | Prints out statistics at the end of each connection.
delay | `[-delay:<value>[units]]` | Delay, with an optional unit (def unit is us), to be introduced before the server responds to a request. (default:0)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
delay | `[-delay:<value>[units]]` | Delay, with an optional unit (def unit is us), to be introduced before the server responds to a request. (default:0)
delay | `[-delay:<value>[units]]` | Delay, with an optional unit (def unit is us), to be introduced before the server responds to a request.

CXPLAT_THREAD_CALLBACK(DelayWorker::WorkerThread, Context)
{
DelayWorker* This = (DelayWorker*)Context;
CXPLAT_EXECUTION_STATE DummyState = {
Copy link
Member

Choose a reason for hiding this comment

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

You're never using CXPLAT_EXECUTION_STATE anywhere. Go ahead and remove all references.

This->m_Server->SimulateDelay();
This->m_Server->SendResponse(WorkItem->Context, WorkItem->Handle, WorkItem->IsTcp);
delete WorkItem;
InterlockedFetchAndSetBoolean(&This->ExecutionContext.Ready); // We just did work, let's keep this thread hot.
Copy link
Member

Choose a reason for hiding this comment

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

The usage of ExecutionContext and Ready is overkill here. I'm pretty sure we can just remove it. In general, you just need the queue and the wake event I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants