Skip to content

CP-50537: TGroup library to manage the priority and classify xapi execution threads. #6076

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

Conversation

GabrielBuica
Copy link
Contributor

@GabrielBuica GabrielBuica commented Oct 23, 2024

This is the follow up to #6020

The initial phase is to classify the threads between Internal and External.

  • External is the default (for now),
  • Internal are threads that process internal requests coming from smapi.

BVT + BST: 207007 (Dev Run)

@GabrielBuica GabrielBuica force-pushed the private/dbuica/feature/perf/tgroups branch 5 times, most recently from de4fdfe to d2b9a9d Compare October 28, 2024 12:52
@GabrielBuica GabrielBuica marked this pull request as ready for review October 28, 2024 13:08
@GabrielBuica GabrielBuica changed the title TGroup library to manage the priority and classify xapi execution threads. CP-50537: TGroup library to manage the priority and classify xapi execution threads. Oct 28, 2024
@GabrielBuica
Copy link
Contributor Author

GabrielBuica commented Oct 29, 2024

Screenshot 2024-10-29 134453
An example of the current classification under load.

@GabrielBuica GabrielBuica force-pushed the private/dbuica/feature/perf/tgroups branch from d2b9a9d to a831ee4 Compare November 4, 2024 16:13
@GabrielBuica GabrielBuica force-pushed the private/dbuica/feature/perf/tgroups branch 2 times, most recently from 61b3a38 to 578622e Compare November 8, 2024 11:43
@robhoes
Copy link
Member

robhoes commented Nov 18, 2024

This PR has a conflict now.

Creates a new library `Tgroup`, that abstracts and manages groups
of execution threads in xapi.

When xapi is under load, all the threads need to share a single cpu in
dom0 because of  ocaml runtime single-cpu restrictions. This library
is meant to orchestrate the threads in different priority groups.

Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
`set_cgroup` adds the functionality of adding the current thread in a
cgroup based on its creator.

Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
Add functionality of setting the tgroup based on a http header named
`originator`.

Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
Clears the `extra_headers` of `UDSTransport` instance when making a
connection.

Previously, this was done only when tracing was enabled inside the
`with_tracecontext` method to avoid the header duplication when
`make_connection` was used multiple times. Currently, there is not
other use of `add_extra_headers` or other update to the
`_extra_headers`, making it safe to clear it when we make a new
connection.

(`xmlrpclib.Transport` updates the `_extra_headers` attribute only
inside `make_connection` method but we override this method with our
own for `UDSTransport`.)

Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
XenAPI.py now passes an additional originator header when making
requests to xapi, if the "ORIGINATOR" env var is present.
Sm_exec now passes an env var, "ORIGINATOR=SM".

To classify the threads correctly, we first need to determine the
requests originators. This commit makes it possibly to explicitly
state the originators as headers.

Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
For now, the thread executing `Xapi.server_init` and it's children are
classified as External. The only excception are http requests that come
through the smapi internally. If those contain the originator header
with the value set as "sm", the thread executing the request will be
classified as internal.

This represents the first phase of classifing xapi threads as internal
vs external.

Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
Adds a configurable variable in `xapi_globs`, `tgroups_enabled` that is
meant to ask a guard for tgroup classification of the threads. If the
guard is `false` all Tgroups functionality should act as a no op.

For instance, adding the line:

tgroups-enabled = false

will result in the thread classification being skipped.

Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
@GabrielBuica GabrielBuica force-pushed the private/dbuica/feature/perf/tgroups branch from 578622e to efaf3f0 Compare November 19, 2024 09:32
@edwintorok edwintorok merged commit 527e124 into xapi-project:feature/perf Nov 19, 2024
15 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.

5 participants