-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlow_level.tex
111 lines (92 loc) · 5.76 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
\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.
\uabschnitt{Alibaba's \photon}\cite{photon} supports a large number of services
and clients, especially the image service of Alibaba’s container platform,
which supports various Internet services for billions of users.
Also used in some ByteDance services.
\uabschnitt{Alibaba's \libeasy}\cite{libeasy} supports a large number of
servers, including storage, database, etc. Not officially open-sourced, but
has been published as part of some open source projects, such as Oceanbase,
tair, etc.
\uabschnitt{Baidu's \bthread}\cite{bthread} has 1 million+ deployed instances
(not counting clients) and thousands of kinds of services.
\uabschnitt{Tencent's \libco}\cite{libco} is a c/c++ coroutine library that
is widely used in backend service of WeChat, which is the largest IM service
in China, with billions of users.
\uabschnitt{\libgo}\cite{libgo} is developed by Meizu, one of the top mobile
phone vendors in China. Libgo is used in Kiev, Meizu's distributed service
framework for its applications.
\uabschnitt{\statethreads}\cite{state-threads} was first developed by
Netscape, then maintained by SGI and Yahoo!. It is now used in a realtime
media streaming server called \href{https://github.com/ossrs/srs}{SRS}, and
maintained by SRS's developers. \emph{state-threads} was used in the
\href{https://dl.acm.org/doi/10.1145/3302424.3303967}
{distributed block store for Meituan}, another top Internet company in China.
\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.}