-
Notifications
You must be signed in to change notification settings - Fork 29
design: Xapi should process events from xenopsd in a timely manner #222
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| --- | ||
| layout: default | ||
| title: Process events from xenopsd in a timely manner | ||
| design_doc: true | ||
| status: proposed | ||
| revision: 1 | ||
| --- | ||
|
|
||
| # Background | ||
|
|
||
| There is a significant delay between the VM being unpaused and XAPI reporting it | ||
| as started during a bootstorm. | ||
| It can happen that the VM is able to send UDP packets already, but XAPI still reports it as not started for minutes. | ||
|
|
||
| XAPI currently processes all events from xenopsd in a single thread, the unpause | ||
| events get queued up behind a lot of other events generated by the already | ||
| running VMs. | ||
|
|
||
| We need to ensure that unpause events from xenopsd get processed in a timely | ||
| manner, even if XAPI is busy processing other events. | ||
|
|
||
| # Timely processing of events | ||
|
|
||
| If we process the events in a Round-Robin fashion then `unpause` events are reported in a timely fashion. | ||
| We need to ensure that events operating on the same VM are not processed in parallel. | ||
|
|
||
| Xenopsd already has code that does exactly this, the purpose of the [xapi-work-queues refactoring PR](https://github.com/xapi-project/xenopsd/pull/337) is to | ||
| reuse this code in XAPI by creating a shared package between xenopsd and xapi: `xapi-work-queues`. | ||
|
|
||
| # xapi-work-queues | ||
|
|
||
| From the documentation of the new [Worker Pool interface](https://edwintorok.github.io/xapi-work-queues/Xapi_work_queues.html): | ||
|
|
||
| A worker pool has a limited number of worker threads. | ||
| Each worker pops one tagged item from the queue in a round-robin fashion. | ||
| While the item is executed the tag temporarily doesn't participate in round-robin scheduling. | ||
| If during execution more items get queued with the same tag they get redirected to a private queue. | ||
| Once the item finishes execution the tag will participate in RR scheduling again. | ||
|
|
||
| This ensures that items with the same tag do not get executed in parallel, | ||
| and that a tag with a lot of items does not starve the execution of other tags. | ||
|
|
||
| The XAPI side of the changes will [look like this](https://github.com/edwintorok/xen-api/commit/b367bf86d3af4f773db9bf5d1500a4dec0f99bfa?diff=unified#diff-344dc1d17c4663add7fe5500813feef2) | ||
|
|
||
| Known limitations: The active per-VM events should be a small number, this is already ensured in the `push_with_coalesce` / `should_keep` code on the [xenopsd side](https://github.com/xapi-project/xenopsd/blob/master/lib/xenops_server.ml#L441). Events to XAPI from xenopsd should already arrive coalesced. | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the relevant code that processes events from xenopsd in xapi is somewhere here: https://github.com/xapi-project/xen-api/blob/master/ocaml/xapi/xapi_xenops.ml#L1204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event loop for xenopsd->xapi is here in
events_watch: https://github.com/xapi-project/xen-api/blob/master/ocaml/xapi/xapi_xenops.ml#L1919, and it calls the module you mentioned.