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

Merged
merged 6 commits into from
Nov 25, 2024
Merged

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.

@nigoroll nigoroll force-pushed the transport_disembark branch 2 times, most recently from 357f202 to 4fd6489 Compare November 9, 2024 19:52
@nigoroll nigoroll force-pushed the transport_disembark branch from 4fd6489 to 0238f28 Compare November 18, 2024 14:45
@nigoroll
Copy link
Member Author

force-pushed after #4224 merge

@nigoroll
Copy link
Member Author

bugwash: OK, need to resolve conflicts, will merge then

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.
@nigoroll nigoroll force-pushed the transport_disembark branch from 0238f28 to 0cfd6cd Compare November 25, 2024 17:28
@nigoroll nigoroll merged commit 0cfd6cd into varnishcache:master Nov 25, 2024
1 of 11 checks passed
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