work_stealing

command
v0.0.0-...-79fdc3c Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

README

Work Stealing

Work Stealing is a scheduling strategy used in concurrent computing to optimize the use of processing resources. It involves dynamically redistributing tasks among processors (or threads) to balance the workload and improve efficiency.

Ideally, each processor maintains a local queue of tasks. When a processor becomes idle, it steals tasks from queues of other processors that still have work to do.

How Can We Implement Work Stealing?

Implementing work stealing involves a few key components:

  1. Task Queues: Each worker (or processor) maintains a local queue of tasks. These queues are typically double-ended, allowing efficient push and pop operations from both ends.
  2. Stealing Mechanism: When a worker's queue becomes empty, the worker looks for other queues with tasks. The worker then steals tasks from the front (oldest tasks) of another worker's queue, while that worker continues to push new tasks to the back.
  3. Synchronization: Since multiple workers may access queues concurrently, appropriate synchronization mechanisms (e.g., locks) are needed to ensure data consistency and prevent race conditions.

How does it help ?

  1. Load balancing
  2. Improved resource utilization
  3. Scalability

Where should we use work stealing ?

  1. Parallel Programming Libraries
  2. Web Servers
  3. Data Processing Frameworks

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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