Skip to content

Skip CcdCallBacks() when no timer callbacks are registered - #198

Merged
ritvikrao merged 1 commit into
mainfrom
ccd-shortcircuit
Aug 3, 2026
Merged

Skip CcdCallBacks() when no timer callbacks are registered#198
ritvikrao merged 1 commit into
mainfrom
ccd-shortcircuit

Conversation

@ritvikrao

Copy link
Copy Markdown
Collaborator

CsdScheduler and CsdSchedulePoll called CcdCallBacks() unconditionally on every trip round the loop. That costs a CmiWallTimer() (~60 ns on Delta) plus a heap probe per iteration even when no timer callback exists, which is the case for any program that does not register one.

Restore the original Converse guard: CcdNumTimerCBs() > 0 collapses the whole thing to one predictable branch when nothing is timer-based, and the _ccd_numchecks countdown bounds the cost when something is. _ccd_numchecks was already declared here but never used to gate anything; the adaptive nSkip retuning that maintains it had been dropped in the port and is restored alongside it.

Verified against tests/conds: the 1s/5s/10s periodic conditions and the 7s CcdCallFnAfter all still fire, with no added lag.

CsdScheduler and CsdSchedulePoll called CcdCallBacks() unconditionally on
every trip round the loop.  That costs a CmiWallTimer() (~60 ns on Delta)
plus a heap probe per iteration even when no timer callback exists, which
is the case for any program that does not register one.

Restore the original Converse guard: CcdNumTimerCBs() > 0 collapses the
whole thing to one predictable branch when nothing is timer-based, and the
_ccd_numchecks countdown bounds the cost when something is.  _ccd_numchecks
was already declared here but never used to gate anything; the adaptive
nSkip retuning that maintains it had been dropped in the port and is
restored alongside it.

Verified against tests/conds: the 1s/5s/10s periodic conditions and the
7s CcdCallFnAfter all still fire, with no added lag.
@ritvikrao
ritvikrao merged commit 45fdf71 into main Aug 3, 2026
2 checks passed
@ritvikrao
ritvikrao deleted the ccd-shortcircuit branch August 3, 2026 13:37
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