Boost.Pipeline Scheduling
● read_socket | process_req | write_socket
● Goals:
– high throughput
– low latency
● Constraints:
– order of requests matter
– reentrancy of transformations are not
guaranteed
Legend
● Segment
● Thread executing segment
● Request
● Queue
Input
Pipeline setup
Threads working
Input
21
Input
Yield to offender
Queue is full, Thread 2 must yield. Since the downstream
queue is offending, the third segment should be chosen.
21
Input
Thread migrated to other
segment
Thread 2 now executes the third segment. However, the contex
of the transformation in the second segment is kept.
21
Input
Managing slow threads
The work in the third segment is heavy, thread 2 falls behind.
Thread 1 should yield, but the offender segment is already
running.
12
Input
Yield to other
This case thread 1 should choose the latest segment
in the pipeline with a non-empty input queue.
Requirements
● Yield between segments
(coroutines/fibers)
● Ability to pinpoint offender task,
check if it's already running
● Ability to tell which is the latest non-
running segment with non-empty input
queue (and execute it)
Extra: Low-load, low latency
● If the input frequency is low, application
writer should be able to opt for pass-
through mode: threads following the
leader follower pattern. Each request is
processed by the next available thread,
thread runs through the whole pipeline
and returns to the pool.
● No N-* transformation is allowed.

Boost.Pipeline scheduling of segments

  • 1.
    Boost.Pipeline Scheduling ● read_socket| process_req | write_socket ● Goals: – high throughput – low latency ● Constraints: – order of requests matter – reentrancy of transformations are not guaranteed
  • 2.
    Legend ● Segment ● Threadexecuting segment ● Request ● Queue
  • 3.
  • 4.
  • 5.
    21 Input Yield to offender Queueis full, Thread 2 must yield. Since the downstream queue is offending, the third segment should be chosen.
  • 6.
    21 Input Thread migrated toother segment Thread 2 now executes the third segment. However, the contex of the transformation in the second segment is kept.
  • 7.
    21 Input Managing slow threads Thework in the third segment is heavy, thread 2 falls behind. Thread 1 should yield, but the offender segment is already running.
  • 8.
    12 Input Yield to other Thiscase thread 1 should choose the latest segment in the pipeline with a non-empty input queue.
  • 9.
    Requirements ● Yield betweensegments (coroutines/fibers) ● Ability to pinpoint offender task, check if it's already running ● Ability to tell which is the latest non- running segment with non-empty input queue (and execute it)
  • 10.
    Extra: Low-load, lowlatency ● If the input frequency is low, application writer should be able to opt for pass- through mode: threads following the leader follower pattern. Each request is processed by the next available thread, thread runs through the whole pipeline and returns to the pool. ● No N-* transformation is allowed.