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

Fix scheduler perf dropping after 128 seconds #2304

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

bfredl
Copy link
Collaborator

@bfredl bfredl commented Jul 18, 2024

Currently, there is a massive increase in scheduler overhead happening after roughly 128 seconds after boot up. As an example, here is scheduler stats before and after when the deluge is idle in an empty song:

Before (typical numbers):

task_scheduler.cpp:451: Dumping task manager stats: (min/ average/ max)
task_scheduler.cpp:470: Load: 84.20 Average Duration: 13.628 Times Called: 340283, Task: audio routine
task_scheduler.cpp:470: Load: 1.59 Average Duration: 5.730 Times Called: 19062, Task: read encoders
......
task_scheduler.cpp:478: Working time: 55.94, Overhead: 44.20. Total running time: 120.00 seconds

After (typical numbers):
task_scheduler.cpp:451: Dumping task manager stats: (min/ average/ max)
task_scheduler.cpp:470: Load: 58.62 Average Duration: 33.665 Times Called: 18188, Task: audio routine
task_scheduler.cpp:470: Load: 4.59 Average Duration: 4.393 Times Called: 9922, Task: read encoders
....
task_scheduler.cpp:478: Working time: 10.06, Overhead: 89.94. Total running time: 140.00 seconds

After chasing a few false ends (I was convinced it was a rollover related bug, as rolltime is 128.86 seconds), there is a bug in chooseBestTask() as the deadline is not being setup anymore, which leads to the default value of double mustEndBefore = 128; being unchanged. after this, most logic in chooseBestTask stops working as intended.

To fix it, add a proper check for running the scheduler without deadline.

Copy link
Contributor

github-actions bot commented Jul 18, 2024

Test Results

75 tests   75 ✅  0s ⏱️
13 suites   0 💤
13 files     0 ❌

Results for commit e72704e.

♻️ This comment has been updated with latest results.

@@ -386,6 +387,9 @@ void TaskManager::start(double duration) {
if (duration != 0) {
mustEndBefore = startTime + duration;
}
else {
mustEndBefore = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we just set this in the constructor? There's no reason to initialize it to 128 anymore, it was a holdover from before the clock rolled properly

Copy link
Collaborator Author

@bfredl bfredl Jul 18, 2024

Choose a reason for hiding this comment

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

I thought it was weird to ignore the duration parameter if it is zero, it will not work if you call start() first with a timeout and later without a timeout.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hm true

Currently, there is a massive increase in scheduler overhead
happening after roughly 128 seconds after boot up. As an example, here
is scheduler stats before and after when the deluge is idle in an empty
song:

Before (typical numbers):

task_scheduler.cpp:451: Dumping task manager stats: (min/ average/ max)
task_scheduler.cpp:470: Load: 84.20 Average Duration: 13.628 Times Called: 340283, Task: audio routine
task_scheduler.cpp:470: Load: 1.59 Average Duration: 5.730 Times Called: 19062, Task: read encoders
......
task_scheduler.cpp:478: Working time: 55.94, Overhead: 44.20. Total running time: 120.00 seconds

After (typical numbers):
task_scheduler.cpp:451: Dumping task manager stats: (min/ average/ max)
task_scheduler.cpp:470: Load: 58.62 Average Duration: 33.665 Times Called: 18188, Task: audio routine
task_scheduler.cpp:470: Load: 4.59 Average Duration: 4.393 Times Called: 9922, Task: read encoders
....
task_scheduler.cpp:478: Working time: 10.06, Overhead: 89.94. Total running time: 140.00 seconds

After chasing a few false ends (I was convinced it was a rollover related
bug, as rolltime is 128.86 seconds), there is a bug in chooseBestTask()
as the deadline is not being setup anymore, which leads to the default
value of `double mustEndBefore = 128;` being unchanged. after this,
most logic in chooseBestTask stops working as intended.

To fix it, add a proper check for running the scheduler without deadline.
@m-m-adams m-m-adams added this pull request to the merge queue Jul 18, 2024
Merged via the queue into SynthstromAudible:community with commit 91f5c69 Jul 18, 2024
6 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.

2 participants