Skip to content

sch: don't receive front signal all the time#42

Merged
Gerold103 merged 1 commit intomasterfrom
front-signal-opt
Apr 28, 2025
Merged

sch: don't receive front signal all the time#42
Gerold103 merged 1 commit intomasterfrom
front-signal-opt

Conversation

@Gerold103
Copy link
Owner

No need to receive it on each scheduling iteration. Under a high load it won't change anything, because the queue is never empty. The signal would be set again right away after receiving.

OTOH, not consuming it on each iteration doesn't break the logic, because when the scheduler has nothing to do, it will sleep on the signal. And if it was set, it would then be received.

This optimization leads to a spurious wakeup under no load. But removes a needless signal receipt on a hot path.

The benchmarks though didn't show any difference. At least on Apple Silicon M1. Anyway, this is now less code and the TLA+ model is still correct and is slightly simpler.

No need to receive it on each scheduling iteration. Under a high
load it won't change anything, because the queue is never empty.
The signal would be set again right away after receiving.

OTOH, not consuming it on each iteration doesn't break the logic,
because when the scheduler has nothing to do, it will sleep on the
signal. And if it was set, it would then be received.

This optimization leads to a spurious wakeup under no load. But
removes a needless signal receipt on a hot path.

The benchmarks though didn't show any difference. At least on
Apple Silicon M1. Anyway, this is now less code and the TLA+ model
is still correct and is slightly simpler.
@Gerold103 Gerold103 self-assigned this Apr 28, 2025
@Gerold103 Gerold103 merged commit 6c8faf1 into master Apr 28, 2025
24 checks passed
@Gerold103 Gerold103 deleted the front-signal-opt branch April 28, 2025 22:11
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.

1 participant