Skip to content

[k2] simplify scheduler API and RPC timeout normalization#1534

Merged
apolyakov merged 5 commits intomasterfrom
apolyakov/k2-fix-normalize-timeout
Feb 26, 2026
Merged

[k2] simplify scheduler API and RPC timeout normalization#1534
apolyakov merged 5 commits intomasterfrom
apolyakov/k2-fix-normalize-timeout

Conversation

@apolyakov
Copy link
Contributor

@apolyakov apolyakov commented Feb 21, 2026

Fix timeout handling issues and consolidate scheduler methods:

  • Add minimum 1ms step for timer resets to prevent platform issues with sub-millisecond timeouts in timer-handle.h

  • Simplify io_scheduler API by unifying methods:

    • schedule() now can accept duration for delayed execution
    • Remove yield() -> use schedule()
    • Remove yield_for() -> use schedule(duration)
    • Remove schedule_after() -> use schedule(duration)
  • Add kphp::concepts::duration concept for type-safe duration params

  • Update RPC timeout normalization to use std::clamp with explicit MIN_TIMEOUT (1ms), MAX_TIMEOUT (24h), DEFAULT_TIMEOUT (300ms)

  • Do not use normalization timeout utility in sched_yield_sleep

  • Update all call sites to use the new unified API

Fix timeout handling issues and consolidate scheduler methods:
- Add minimum 1ms step for timer resets to prevent platform issues
  with sub-millisecond timeouts in timer-handle.h

- Simplify io_scheduler API by unifying methods:
  - schedule() now accepts optional duration for delayed execution
  - Remove yield() -> use schedule()
  - Remove yield_for() -> use schedule(duration)
  - Remove schedule_after() -> use schedule(duration)
  - All timeouts now use milliseconds consistently

- Add kphp::concepts::duration concept for type-safe duration params

- Update RPC timeout normalization to use std::clamp with explicit
  MIN_TIMEOUT (1ms), MAX_TIMEOUT (24h), DEFAULT_TIMEOUT (300ms)

- Update all call sites to use the new unified API
@apolyakov apolyakov changed the title [k2] fix timeout normalization and simplify scheduler API [k2] simplify scheduler API and RPC timeout normalization Feb 21, 2026
@apolyakov apolyakov marked this pull request as ready for review February 24, 2026 08:11
@apolyakov apolyakov self-assigned this Feb 24, 2026
@apolyakov apolyakov added the k2 k2 related label Feb 24, 2026
@apolyakov apolyakov added this to the next milestone Feb 24, 2026
@apolyakov apolyakov requested a review from Shamzik February 25, 2026 14:42
Shamzik
Shamzik previously approved these changes Feb 25, 2026
KPHP-CI
KPHP-CI previously approved these changes Feb 25, 2026
Copy link

@KPHP-CI KPHP-CI left a comment

Choose a reason for hiding this comment

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

Excellent work!

@apolyakov apolyakov dismissed stale reviews from KPHP-CI and Shamzik via 9252c56 February 26, 2026 14:03
Copy link
Contributor

@PetrShumilov PetrShumilov left a comment

Choose a reason for hiding this comment

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

OK

@apolyakov apolyakov merged commit 754d9cb into master Feb 26, 2026
7 checks passed
@apolyakov apolyakov deleted the apolyakov/k2-fix-normalize-timeout branch February 26, 2026 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

k2 k2 related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants