bgpriority

package
v2.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package bgpriority lowers the scheduling priority of dedicated background worker goroutines so long-running work (media indexing, scraping) yields CPU and storage bandwidth to foreground activity. Only Linux has the required per-thread controls; on other platforms Apply is a no-op.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply()

Apply locks the calling goroutine to its OS thread and drops that thread to the lowest CPU and IO scheduling priority (nice 19, SCHED_IDLE, IOPRIO_CLASS_IDLE). Call it at the top of a dedicated background worker goroutine. The goroutine must not call runtime.UnlockOSThread: keeping the thread locked until the goroutine exits makes the runtime destroy the thread, so the lowered priorities never leak to other goroutines.

IO priority is honored by the bfq and mq-deadline (kernel 5.13+) block schedulers and ignored by none; CPU changes apply everywhere. All failures are logged and non-fatal — the caller continues at normal priority in the worst case.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL