Skip to main content

deprioritize_background_threads

Function deprioritize_background_threads 

Source
pub fn deprioritize_background_threads()
Expand description

Deprioritizes known background threads spawned by third-party libraries (OpenTelemetry, tracing-appender, reqwest) by scanning /proc/<pid>/task/ for matching thread names and setting SCHED_IDLE scheduling policy + maximum niceness on them.

This is a hack: these threads are spawned by libraries that do not expose a way to hook into thread initialization or expose the TIDs, so we have to discover them after the fact by reading /proc.

Should be called once after tracing is initialized.

No-op on non-Linux platforms.