Skip to main content

Module platform_scheduler

Module platform_scheduler 

Source
Expand description

Platform-aware thread QoS and core-affinity binding.

Binds the calling thread to the most appropriate processor class for its workload so the OS scheduler makes the right placement decision:

ClassmacOS QoSLinuxWindows
UserInteractiveQOS_CLASS_USER_INTERACTIVEP-cores (affinity)THREAD_PRIORITY_HIGHEST
UserInitiatedQOS_CLASS_USER_INITIATEDP-coresTHREAD_PRIORITY_ABOVE_NORMAL
DefaultQOS_CLASS_DEFAULTanyTHREAD_PRIORITY_NORMAL
UtilityQOS_CLASS_UTILITYanyTHREAD_PRIORITY_BELOW_NORMAL
BackgroundQOS_CLASS_BACKGROUNDE-cores (affinity)THREAD_PRIORITY_IDLE

Apple Silicon AMP (P-cores + E-cores) is the primary target. On Intel/AMD/ARM64 the distinction collapses to thread priority.

Enums§

QosClass
SchedulerError

Functions§

bind_background_thread
Convenience wrapper: bind to Background (E-core / idle priority). Call from WAL flush, Merkle DAG, ambient orchestration threads.
bind_current_thread
Bind the calling thread to class.
bind_inference_thread
Convenience wrapper: bind to UserInteractive (P-core / max priority). Call from the LLM inference thread and active SPARQL query thread.
current_qos_class
Read the QoS class of the calling thread. Returns None on non-macOS.