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

Transport disembark #4220

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

nigoroll
Copy link
Member

@nigoroll nigoroll commented Nov 2, 2024

This is the next chapter of the book of AI, see #4209

To eventually get to event driven, asynchronous IO where a smaller number of threads handles a large number of requests, we also need a way to disembark a request from a worker and have another thread pick up where it left of, then reentering the state machine later to finish off.

Thanks to the already existing disembark facility used for waitinglist wakeups, implementing this is pretty straight forward: We basically only need to allow the vtr_deliver_f (transport deliver function) to tell the state engine to disembark, add a "finish" state, and everything else more or less works out of the box.

The last commit has a demonstration in a test case.

Everything else in this patch is refactoring.

…y once

This allows to re-use http1_new_session from custom implementations, in that it
can serve as an entry point into the state machine also for existing sessions
(without requiting 8 bytes of session workspace for each request served).
This allows code-reuse from custom implementations where only the deliver
deliver callback differs.
This is in preparation of simplifications and to be able disembark during
delivery.
now that boc lives in struct req, it is obsolete

also change some subordinate helper functions
To prepare for the next commit, we introduce a new finish step to the request
FSM, which is just the former tail of cnt_transmit().
This allows the transport's delivery function to disembark the thread by
returning VTR_D_DISEMBARK. In this case, CNT_Request() needs to be called at a
later time to continue.

It is the vtr_deliver_f's responsibility to clear req->wrk because only it can
ensure proper synchronization with another thread which might already be
running.
vmod_debug_transports.c demonstrates the basic mechanics of disembarking a
request from the vrt_deliver_f, delivering a body from another worker and
finishing the request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant