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

CP-52745: Add ThreadLocalStorage in Threadext #6354

Merged
merged 1 commit into from
Apr 11, 2025

Conversation

GabrielBuica
Copy link
Contributor

@GabrielBuica GabrielBuica commented Mar 12, 2025

Adds a ThreadLocalStorage module under Threadext. Currently, it
uses Ambient_local.Thread_local as the underlying implementation.

Following the thread classification PRs, #6154, this will enable
accessing the current thread group for each thread. The current data
structure contains the following:

  1. ocaml_tid
  2. thread_name
  3. time_running
  4. tepoch
  5. tgroup

Field 1: ocaml_tid is equivalent to Thread.self () |> Thread.id.
Field 2: thread_name is to associet threads with human readable
string.
Fields 3-5:

  • time_runinng - the amount of time the thread has been running in
    the current OCaml runtime timeslice,
  • tepoch - the current timeslice the thread has been scheduled for,
  • tgroup - current thread classification.

Fields 3-5 are what is expected to be used for thread scheduling when
xapi is under load. (This will be a future PR.)

This can be extended in the future to contain information about tracing,
such as traceparent and baggage.

@psafont
Copy link
Member

psafont commented Mar 12, 2025

Please, explain the benefits of the change in the PR and the commit message

@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-52745 branch from b4e984b to e8dbeb8 Compare March 12, 2025 16:09
@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-52745 branch from e8dbeb8 to 0645f28 Compare March 26, 2025 16:48
@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-52745 branch 2 times, most recently from baa4967 to a6cb96f Compare April 9, 2025 14:39
Copy link
Contributor

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

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

I think we now have a user of this code, and the interface is simpler.

@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-52745 branch from a6cb96f to ab1257f Compare April 9, 2025 15:46
Adds a `ThreadLocalStorage` module under `Threadext`. Currently, it
uses `Ambient_local.Thread_local` as the underlying implementation.

Following the thread classification PRs,
xapi-project#6154, this will enable
accessing the current thread group for each thread. The current data
structure contains the following:

1. ocaml_tid
2. thread_name
3. time_running
4. tepoch
5. tgroup

Field 1: `ocaml_tid` is equivalent to `Thread.self () |> Thread.id.`
Field 2: `thread_name` is to associet threads with human readable
string.
Fields 3-5:
- `time_runinng` - the amount of time the thread has been running in
 the current OCaml runtime timeslice,
- `tepoch` - the current timeslice the thread has been scheduled for,
- `tgroup` - current thread classification.

Fields 3-5 are what is expected to be used for thread scheduling when
xapi is under load.

This can be extended in the future to contain information about tracing,
such as `traceparent` and `baggage`.

Signed-off-by: Gabriel Buica <[email protected]>
@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-52745 branch from ab1257f to f2b848d Compare April 10, 2025 13:22
@psafont psafont added this pull request to the merge queue Apr 11, 2025
Merged via the queue into xapi-project:master with commit bf4dce3 Apr 11, 2025
17 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