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

scx_bpfland: introduce dynamic nvcsw threshold #439

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

arighi
Copy link
Contributor

@arighi arighi commented Jul 18, 2024

Instead of using a static value to classify tasks based on their average amount of voluntary context switches, try to periodically evaluate an optimal threshold, based on a global average of voluntary context switches among of all the running tasks.

Tasks with an average amount of voluntary context switches greater than the global average will be classified as interactive.

The global average is evaluated as an exponentially weighted moving average (EWMA), as:

avg(t) = avg(t - 1) * 0.75 - task_avg(t) * 0.25

This approach is more efficient than iterating through all tasks and it helps to prevent rapid fluctuations that may be caused by bursts of voluntary context switch events.

The dynamic nvcsw threshold enables a more precise adjustment of the classification criteria to swiftly respond to global system changes: tasks can be quickly classified as interactive, but if the system experiences too many interactive events, the criteria for maintaining interactive status become stricter. This creates a natural selection process where only the most deserving tasks remain interactive.

Additionally, introduce the new option --nvcsw-max-thresh N, which allows to extend or restrict the fluctuation range of the global average threshold for voluntary context switches.

@sirlucjan
Copy link
Contributor

Feel free to add

Tested-by: Piotr Gorski [email protected]

Instead of using a static value to classify tasks based on their average
amount of voluntary context switches, try to periodically evaluate an
optimal threshold, based on a global average of voluntary context
switches among of all the running tasks.

Tasks with an average amount of voluntary context switches greater than
the global average will be classified as interactive.

The global average is evaluated as an exponentially weighted moving
average (EWMA), as:

  avg(t) = avg(t - 1) * 0.75 - task_avg(t) * 0.25

This approach is more efficient than iterating through all tasks and it
helps to prevent rapid fluctuations that may be caused by bursts of
voluntary context switch events.

The dynamic nvcsw threshold enables a more precise adjustment of
the classification criteria to swiftly respond to global system changes:
tasks can be quickly classified as interactive, but if the system
experiences too many interactive events, the criteria for maintaining
interactive status become stricter. This creates a natural selection
process where only the most deserving tasks remain interactive.

Additionally, introduce the new option `--nvcsw-max-thresh N`, which
allows to extend or restrict the fluctuation range of the global average
threshold for voluntary context switches.

Tested-by: Piotr Gorski <[email protected]>
Signed-off-by: Andrea Righi <[email protected]>
@arighi arighi force-pushed the bpfland-dynamic-nvcsw-thresh branch from d4d84c5 to c4eb3ce Compare July 18, 2024 17:04
@arighi arighi merged commit cb86768 into main Jul 18, 2024
1 check passed
@arighi arighi deleted the bpfland-dynamic-nvcsw-thresh branch July 18, 2024 18:38
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.

3 participants