Timing Wheel Scheduler Halting and Lock Segmentation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Timing wheel schedulers in computing systems face inefficiencies due to unnecessary CPU consumption when there are no tasks to schedule, and the use of a global lock leads to contention and reduced concurrency, especially at lower timing wheel granularities.

Innovation Solution

Implementing a method to halt the timing wheel when there are no tasks, using a lock-free algorithm with atomic operations, replacing the global lock with locks per array slot, and utilizing a ring buffer data structure to allow concurrent task addition and scheduling contexts, with a separate data structure for missed tasks to ensure timely scheduling.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If the timing wheel scheduler continuously runs to manage tasks, then task scheduling capability is maintained, but CPU consumption increases unnecessarily when there are no tasks

Engineering Contradiction:
Improvetask scheduling capabilityVSAvoidCPU consumption
Core Design Contradiction:
ReliabilityVSUse of energy by moving object

Solution Approach 1:

The timing wheel scheduler is made dynamic by introducing a halted state where it stops executing when no tasks are present. The scheduler transitions between running and halted states based on task availability, allowing it to adapt its execution behavior to minimize CPU consumption while maintaining scheduling capability when needed.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The scheduler checks for tasks periodically rather than continuously processing. When halted, it remains in a low-power state and is awakened only when new tasks arrive, implementing a periodic check mechanism that reduces CPU consumption compared to continuous operation.

Inventive Principle:
Principle #19Periodic action

2Reliability

If a global lock is used to protect the timing wheel data structure, then data consistency is ensured, but concurrency is reduced due to lock contention

Engineering Contradiction:
Improvedata consistencyVSAvoidconcurrency
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The global lock is segmented into per-index locks, where each index in the timing wheel array has its own lock. This segmentation allows multiple indexes to be accessed concurrently by different threads, reducing lock contention while maintaining data consistency through proper lock scope management.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

Different parts of the timing wheel data structure have different locking requirements. The per-index locks provide local protection for each index's task list, allowing independent concurrent access to different indexes while ensuring consistency within each indexed region.

Inventive Principle:
Principle #3Local quality

3Reliability

If task addition and scheduling contexts run sequentially with a global lock, then data integrity is maintained, but scheduling efficiency decreases

Engineering Contradiction:
Improvedata integrityVSAvoidscheduling efficiency
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The locking mechanism is segmented to allow task addition and scheduling contexts to run in parallel on different indexes. Each context acquires the appropriate per-index lock only when needed, enabling concurrent execution that improves scheduling efficiency while maintaining data integrity through proper synchronization.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The system uses atomic operations to perform preliminary checks and updates before full locking is required. This allows some scheduling operations to proceed without full lock protection, improving efficiency while maintaining correctness through atomic atomicity guarantees.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentEP4379546A1Task scheduling using timing wheel data structure
Publication Date: 2024.06.05 LEMON INC(GB)
  • EP4379546A1 patent drawingFigure 1~3
  • EP4379546A1 patent drawingFigure 4
  • EP4379546A1 patent drawingFigure 5~6

AI summary

In order to more efficiently use a timing wheel data structure, the timing wheel is halted when there are no tasks in the timing wheel data structure. A current task count across all timing wheel indexes may be stored so that the halting only occurs when the current task count is zero. Instead of a global lock on the timing wheel data structure, task scheduling contexts may be allowed to run concurrently within different indexes while scheduling contexts are forced to run in series within each index. Each index of the timing wheel may comprise a ring buffer. A method of operation may comprise identifying tasks which are missed by a scheduling context; adding identified tasks to a separate data structure; checking the separate data structure for pending tasks; and prioritising scheduling tasks from the separate data structure.