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

External Execution Interface #4616

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

External Execution Interface #4616

wants to merge 16 commits into from

Conversation

nibanks
Copy link
Member

@nibanks nibanks commented Oct 16, 2024

Description

Closes #1923.

Provides an interface for the application layer to completely control execution of all MsQuic work. In other words, MsQuic would create no threads internally.

Testing

TODO

Documentation

TODO

@nibanks nibanks added Area: Performance Area: API Area: Core Related to the shared, core protocol logic labels Oct 16, 2024
src/inc/msquic.h Outdated Show resolved Hide resolved
@nibanks nibanks changed the title Initial External Execution Interface External Execution Interface Oct 16, 2024
src/inc/msquic.h Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.60%. Comparing base (f16a46b) to head (919ae67).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4616      +/-   ##
==========================================
- Coverage   87.20%   86.60%   -0.60%     
==========================================
  Files          56       56              
  Lines       17363    17378      +15     
==========================================
- Hits        15141    15051      -90     
- Misses       2222     2327     +105     

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

QUIC_STATUS Status = MsQuic->ExecutionCreate(QUIC_EXECUTION_CONFIG_FLAG_NONE, 0, 1, &ExecConfig, &ExecContext);
```

The above code createa a new IOCP (for Windows), sets up an execution config, indicating an ideal processor of 0 and the pointer to the IOCP, and then calls MsQuic to create 1 execution context.
Copy link
Contributor

Choose a reason for hiding this comment

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

A processor of 0 has no clear, unambiguous meaning on Win32. A PROCESSOR_NUMBER is the only unambiguous processor identifier in Windows user mode, unless MsQuic provides its own canonical representation to apps.

Copy link
Contributor

@mtfriesen mtfriesen Jan 6, 2025

Choose a reason for hiding this comment

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

One could argue that 0 should always map to Group 0, Number 0 in any sensible CPU numbering scheme, but certainly once you reach the integer 1, the point stands. The NT processor index 1 could be Group 1, Number 0, even if Group 0, Number 1 exists, and vice versa.

Copy link
Member Author

Choose a reason for hiding this comment

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

We can look around to see how other platform abstraction layers (std, boost) solve this problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

According to stackoverflow, boost sidesteps the problem by allowing you to get a native thread handle, and then go off and call platform-specific affinity routines yourself. Personally I think an int should be a reasonable way to identify CPUs, so if QUIC just exposes ConvertProcessorNumberToProcessorIndex and ConvertProcessorIndexToProcessorNumber helper routines on Windows, you'd be set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, you could typedef int QUIC_CPU_ID everywhere else and typedef PROCESSOR_NUMBER QUIC_CPU_ID on Windows and let apps deal with the difference if they also compile cross-plat.


To create an execution context, the app much first create an event queue object, which is a platform specific type:

- Windows: IOCP
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we expose a platform specific queue object rather than having a more abstracted interface?

Copy link
Member Author

Choose a reason for hiding this comment

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

Such as what? The reason we use the platform queue object is because that is also a requirement for other (i.e. storage) IO. So, it's not expected to be a new requirement. Also, this is all opt-in. They can continue to use MsQuic without doing this, and it will simply create the background threads still.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant a generic platform-independent interface for queue objects.

So, for the apps to opt in, they still have to create a new IOCP handle exclusively for msquic, right? i.e. they can't just share whatever IOCP handles they use for file IO for msquic unless they change all their IO logic to use the new sqe/cqe pattern.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, they shouldn't create anything specific for MsQuic. If they have an epoll queue (on Linux) for their storage IO, they should reuse that for MsQuic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: API Area: Core Related to the shared, core protocol logic Area: Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow using an app-provided thread
3 participants