-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlow_level.tex
83 lines (70 loc) · 4.36 KB
/
low_level.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
\abschnitt{\fiber as building block for higher-level frameworks}\label{low_level}
A low-level API enables a rich set of higher-level frameworks that provide
specific syntaxes/semantics suitable for specific domains. As an example, the
following frameworks are based on the low-level fiber switching API of
\bcontext\cite{bcontext} (which implements the API proposed here).
\uabschnitt{\bcoroutine}\cite{bcoroutine2} implements \bfs{asymmetric coroutines}
\cpp{coroutine<>::push_type} and\\
\cpp{coroutine<>::pull_type}, providing a
unidirectional transfer of data. These stackful coroutines are only used in
pairs. When \cpp{coroutine<>::push_type} is explicitly
instantiated, \cpp{coroutine<>::pull_type} is synthesized and passed as
parameter into the coroutine function. In the
example below, \cpp{coroutine<>::push_type} (variable \cpp{writer}) provides the
resume operation, while \cpp{coroutine<>::pull_type} (variable \cpp{in})
represents the suspend operation. Inside the lambda,\cpp{in.get()}
pulls strings provided by \cpp{coroutine<>::push_type}'s output iterator support.
\cppf{bcoroutine_ex}
\uabschnitt{\synca}\cite{synca} (by Grigory Demchenko) is a small, efficient
library to perform asynchronous operations using source code that resembles synchronous
operations. The main
features are a \bfs{GO-like} syntax, support for transferring execution context
explicitly between different thread pools or schedulers (portals/teleports) and
asynchronous network support.
\cppf{synca_ex}
The code itself looks like synchronous invocations while internally it uses
asynchronous scheduling.
\uabschnitt{\bfiber}\cite{bfiber} implements \bfs{user-land threads} and combines
fibers with schedulers (the scheduler algorithm is a customization point). The API
is modelled after the \thread API and contains objects such as
\cpp{future}, \cpp{mutex},\\
\cpp{condition_variable} ...
\cppf{bfiber_ex}
\uabschnitt{Facebook's \fbfibers}\cite{fbfiber} is an asynchronous C++ framework
using \bfs{user-land threads} for parallelism. In contrast to \bfiber,
\fbfibers\xspace exposes the scheduler and permits integration with various
event dispatching libraries.
\cppf{fbfiber_ex}
\fbfibers\xspace is used in many critical applications at Facebook for instance
in \fbmcrouter\cite{fbmcrouter} and some other Facebook services/libraries like
ServiceRouter (routing framework for \fbthrift\cite{fbthrift}), Node API (graph
ORM API for graph databases) ...
\uabschnitt{Bloomberg's \bbquantum}\cite{bbquantum} is a full-featured and
powerful C++ framework that allows users to dispatch units of work (a.k.a.
tasks) as coroutines and execute them concurrently using the 'reactor' pattern.
Its main features are support for streaming futures which allows faster processing
of large data sets, task prioritization, fast pre-allocated memory pools and
parallel \cpp{forEach} and \cpp{mapReduce} functions.
\cppf{bbquantum}
\bbquantum\xspace is used in large projects at Bloomberg.
\uabschnitt{Habanero Extreme Scale Software Research Project\cite{habanero}}
provides a task-based parallel programming model via its \hclib\cite{hclib}.
The runtime provides work-stealing, async-finish,\footnote{async-finish is a
variant of the fork-join model. While a task might fork a group of
child tasks, the child tasks might fork even more tasks. All tasks can
potentially run in parallel with each other. The model allows a parent task to
selectively join a subset of child tasks.}
parallel-for and future-promise parallel programming patterns. The library is not an exascale
programming system itself, but it manages intra-node resources and schedules
components within an exascale programming system.
\uabschnitt{Intel's \tbb}\cite{tbb} internally uses fibers for long running
jobs\footnote{because of the requirement to support a broad range of
architectures \href{https://github.com/intel/tbb/blob/tbb_2020/src/tbb/co_context.h\#L190}
{\swapcontext} was used} as reported by Intel.
\uabschnitt{\userver}\cite{userver} is a modern open source asynchronous
framework with a rich set of abstractions, database connectors/drivers,
protocols and synchronization primitives for fast and comfortable creation
of IO-bound C++ microservices, services and utilities.
\zs{As shown in this section a low-level API can act as building block for a
rich set of high-level frameworks designed for specific application domains
that require different aspects of design, semantics and syntax.}