"src/targets/vscode:/vscode.git/clone" did not exist on "1f2622baa1a38aebcb613dbc53583fd917527de4"
orchestration.rst 13.6 KB
Newer Older
Antoine Kaufmann's avatar
Antoine Kaufmann committed
1
..
Antoine Kaufmann's avatar
Antoine Kaufmann committed
2
  Copyright 2022 Max Planck Institute for Software Systems, and
Antoine Kaufmann's avatar
Antoine Kaufmann committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  National University of Singapore
..
  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files (the
  "Software"), to deal in the Software without restriction, including
  without limitation the rights to use, copy, modify, merge, publish,
  distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to
  the following conditions:
..
  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.
..
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

24
25
.. _sec-orchestration:

26
###################################
Antoine Kaufmann's avatar
Antoine Kaufmann committed
27
SimBricks Orchestration
28
29
###################################

30
Our orchestration framework replaces hand-crafted scripts for setting up and
31
32
33
34
35
running experiments. Instead, experiments are described in a declarative
fashion. The orchestration framework then takes care of the details, manages
launching the respective component simulators, sets up the SimBricks
communication channels between them, and monitors their execution. All output is
collected in a JSON file, which allows easy post-processing afterwards. 
36

Antoine Kaufmann's avatar
Antoine Kaufmann committed
37
38
39
40
******************************
Concepts
******************************

41
42
43
To declare experiments, we use multiple important concepts and terminology,
which we now introduce.

Antoine Kaufmann's avatar
Antoine Kaufmann committed
44
45
46
Experiments
===========

47
48
49
50
51
An *experiment* defines which component simulators to run and how they are
connected. To define one, instantiate the class
:class:`~simbricks.orchestration.experiments.Experiment` in your own Python
module, which has member functions to further define the component simulators to
run. SimBricks comes with many pre-defined experiments, which can serve as
52
53
starting guides and are located in the repository under
:simbricks-repo:`experiments/pyexps </blob/main/experiments/pyexps>`.
54
55

.. autoclass:: simbricks.orchestration.experiments.Experiment
56
  :members: add_host, add_pcidev, add_nic, add_network, checkpoint
57

Antoine Kaufmann's avatar
Antoine Kaufmann committed
58
59
60
Runs
====

61
62
Experiments can be executed multiple times, for example, to gain statistical
insights when including a random or non-deterministic component. We call each
63
64
execution a *run* of the experiment. Each run produces its own output JSON file.
The file name includes the number of the run.
65
66
67

The number of runs can be specified when invoking the orchestration framework,
see :ref:`sec-command-line`. When using simulator checkpointing, we use one run
68
69
70
to boot the simulator and take the checkpoint, and a second one to carry out the
actual experiment. This is the reason for two output JSON files being produced
in this case. For more information, see :ref:`sec-checkpointing`.
71

Antoine Kaufmann's avatar
Antoine Kaufmann committed
72
73
74
Component Simulators
====================

75
76
77
SimBricks defines multiple, ready-to-use component simulators in the module
:mod-orchestration:`simulators.py`. These include host, NIC, network, and PCIe
device simulators. Each simulator is defined by a class deriving from
78
:class:`~simbricks.orchestration.simulators.Simulator`, which provides the
79
80
81
82
necessary commands for their execution. We also offer more specialized base
classes for the different component types, which implement common member
functions, for example, to connect NICs or network component simulators to a
host simulator.
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
112
113
114
115
116
117
118
119
120
121
122
123
124
.. autoclass:: simbricks.orchestration.simulators.Simulator
  :members: prep_cmds, run_cmd, resreq_cores, resreq_mem

.. autoclass:: simbricks.orchestration.simulators.HostSim
  :members: sync_mode, sync_period, pci_latency, add_pcidev, add_nic, add_netdirect
  :show-inheritance:

.. autoclass:: simbricks.orchestration.simulators.NetSim
  :members: sync_mode, sync_period, eth_latency, connect_network
  :show-inheritance:

.. autoclass:: simbricks.orchestration.simulators.PCIDevSim
  :members: sync_mode, sync_period, pci_latency
  :show-inheritance:

.. autoclass:: simbricks.orchestration.simulators.NICSim
  :members: eth_latency, set_network
  :show-inheritance:

.. _sec-node_app_config:

*******************
Node and App Config
*******************

To configure the workload and the software environment of nodes, use the classes
:class:`~simbricks.orchestration.nodeconfig.NodeConfig` and
:class:`~simbricks.orchestration.nodeconfig.AppConfig`. The former is passed to
every host simulator and defines, for example, the networking configuration like
IP address and subnet mask, how much system memory the node has, but also which
disk image to run. You can read more about the latter under
:ref:`sec-howto-custom_image`.

The :class:`~simbricks.orchestration.nodeconfig.NodeConfig` contains an
attribute for an instance of
:class:`~simbricks.orchestration.nodeconfig.AppConfig`, which defines the
workload or the concrete commands that are executed on the node. You can also
override :meth:`~simbricks.orchestration.nodeconfig.AppConfig.config_files` to
specify additional files to be copied into the host. These are specified as key
value pairs, where the key represents the path/filename inside the simulated
guest system and the value is an IO handle of the file to be copied over.
125

126
127
128
.. autoclass:: simbricks.orchestration.nodeconfig.NodeConfig
  :members: ip, prefix, mtu, cores, memory, disk_image, app, run_cmds,
    cleanup_cmds, config_files 
129

130
131
.. autoclass:: simbricks.orchestration.nodeconfig.AppConfig
  :members: run_cmds, config_files
132

133
*******************************
134
Unsynchronized vs. Synchronized
135
136
*******************************

137
138
139
140
141
142
143
144
145
146
147
148
149
SimBricks offers two modes of operation, unsynchronized and synchronized, which
are defined on a per component basis. The default is the unsynchronized mode
that is meant purely for functional testing. Unsynchronized components advance
virtual time as quickly as they possibly can, which means that measurements
taken on them are meaningless and cross-component measurements inaccurate.

The synchronized mode, in contrast, is meant for accurate measurements and has
to be enabled per component, for example, by setting
:attr:`simbricks.orchestration.simulators.PCIDevSim.sync_mode` or
:attr:`simbricks.orchestration.simulators.HostSim.sync_mode`. Running
synchronized means that a simulator waits to process incoming messages from
connected simulators at the correct timestamps. For technical details, see
:ref:`sec-synchronization`.
Antoine Kaufmann's avatar
Antoine Kaufmann committed
150

151
152
153
154
***************************************
Link Latency and Synchronization Period
***************************************

155
156
157
158
Most of the pre-defined simulators in :mod-orchestration:`simulators.py` provide
an attribute for tuning link latencies and the synchronization period. Both are
configured in nanoseconds and apply to the message flow from the configured
simulator to connected ones.
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

Some simulators have interfaces for different link types, for example, NIC
simulators based on :class:`~simbricks.orchestration.simulators.NICSim` have a
PCIe interface to connect to a host and an Ethernet link to connect to the
network. The link latencies can then be configured individually per interface
type.

The synchronization period defines the simulator's time between sending
synchronization messages to connected simulators. Generally, for accurate
simulations, you want to configure this to the same value as the link latency.
This ensures an accurate simulation. With a lower value we don't lose accuracy,
but we send more synchronization messages than necessary. The other direction is
also possible to increase simulation performance by trading-off accuracy using a
higher setting. For more information, refer to the section on
:ref:`sec-synchronization` in the :ref:`page-architectural-overview`.


176
177
.. _sec-command-line:

Antoine Kaufmann's avatar
Antoine Kaufmann committed
178
179
180
181
******************************
Running Experiments
******************************

182
To run experiments using our orchestration framework, use the
183
184
185
186
:simbricks-repo:`experiments/run.py </blob/main/experiments/run.py>` script. For
your convenience, you can also use ``simbricks-run`` in the Docker images from
anywhere to run experiments. In practice, running experiments will look similar
to this:
187

188
.. code-block:: bash
Antoine Kaufmann's avatar
Antoine Kaufmann committed
189

190
  $ python run.py --verbose --force pyexps/simple_ping.py
191
  # only available inside docker images
192
  $ simbricks-run --verbose --force pyexps/simple_ping.py
193

194
195
Here are all the command line arguments for the
:simbricks-repo:`experiments/run.py </blob/main/experiments/run.py>` script:
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

.. code-block:: text

  usage: run.py [-h] [--list] [--filter PATTERN [PATTERN ...]] [--pickled] [--runs N]
                [--firstrun N] [--force] [--verbose] [--pcap] [--repo DIR] [--workdir DIR]
                [--outdir DIR] [--cpdir DIR] [--hosts JSON_FILE] [--shmdir DIR]
                [--parallel] [--cores N] [--mem N] [--slurm] [--slurmdir DIR] [--dist]
                [--auto-dist] [--proxy-type TYPE]
                EXP [EXP ...]

  positional arguments:
    EXP                   Python modules to load the experiments from

  options:
    -h, --help            show this help message and exit
    --list                List available experiment names
    --filter PATTERN [PATTERN ...]
                          Only run experiments matching the given Unix shell style patterns
    --pickled             Interpret experiment modules as pickled runs instead of .py files
    --runs N              Number of repetition of each experiment
    --firstrun N          ID for first run
    --force               Run experiments even if output already exists (overwrites output)
    --verbose             Verbose output, for example, print component simulators\' output
    --pcap                Dump pcap file (if supported by component simulator)

  Environment:
    --repo DIR            SimBricks repository directory
    --workdir DIR         Work directory base
    --outdir DIR          Output directory base
    --cpdir DIR           Checkpoint directory base
    --hosts JSON_FILE     List of hosts to use (json)
    --shmdir DIR          Shared memory directory base (workdir if not set)

  Parallel Runtime:
    --parallel            Use parallel instead of sequential runtime
    --cores N             Number of cores to use for parallel runs
    --mem N               Memory limit for parallel runs (in MB)

  Slurm Runtime:
    --slurm               Use slurm instead of sequential runtime
    --slurmdir DIR        Slurm communication directory

  Distributed Runtime:
    --dist                Use sequential distributed runtime instead of local
    --auto-dist           Automatically distribute non-distributed experiments
    --proxy-type TYPE     Proxy type to use (sockets,rdma) for auto distribution
242
243

******************************
Antoine Kaufmann's avatar
Antoine Kaufmann committed
244
Images
245
246
******************************

247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
All host simulators require a disk image. We already provide a base image with
Ubuntu. If you just want to copy in additional files, e.g., drivers and
executables for your workload, you don't need to build your own image. You can
use the method
:meth:`~simbricks.orchestration.nodeconfig.NodeConfig.config_files` of
:class:`~simbricks.orchestration.nodeconfig.NodeConfig` and
:class:`~simbricks.orchestration.nodeconfig.AppConfig` to mount additional files
under ``/tmp/guest`` inside the simulated OS.

For more than that, you need to build your own images. You can find the commands
to do so in ``images/rules.mk``. When building an image, it is started with Qemu
in a VM with active internet access. The image-specific script located in
``images/scripts`` is then executed on the guest system to modify the image,
e.g., changing config files, installing packages, or building required projects
from source. In order to use your image in experiments, set the attribute
:attr:`~simbricks.orchestration.nodeconfig.NodeConfig.disk_image` on
:class:`~simbricks.orchestration.nodeconfig.NodeConfig`. This requires that your
image is stored as ``images/out-<image_name>/<image_name>``. If your host
simulator requires a raw image, execute ``make
images/out-<image_name>/<image_name>.raw`` to convert your image.

268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
*************************************
Checkpoints
*************************************

Some of our host simulators support taking checkpoints. Using these can
dramatically speed up the boot process by executing two runs for an experiment.
In the first, the simulator is booted in unsynchronized mode using an inaccurate
CPU model. When the boot process is completed meaning the workload defined via
the class :class:`~simbricks.orchestration.nodeconfig.AppConfig` can be
executed, a checkpoint is taken. In the second run, the simulator is switched
into synchronized mode, the CPU model replaced with the accurate one, and the
workload executed. Checkpointing can be enabled by setting the attribute
:attr:`~simbricks.orchestration.experiments.Experiment.checkpoint` on the
:class:`~simbricks.orchestration.experiments.Experiment` class.

When running an experiment multiple times, e.g. because you are tweaking the
workload, the checkpoint doesn't have to be recreated all the time. When
invoking the orchestration framework without the ``--force`` flag (see
:ref:`sec-command-line`), it won't re-execute experiments and runs, for which an
output JSON file already exists. So, if you delete only the output file of the
second run, you can save the time for creating the checkpoint.
289
290

******************************
Antoine Kaufmann's avatar
Antoine Kaufmann committed
291
Distributed Simulations
292
293
******************************

294
295
For the moment, refer to our
:simbricks-repo:`GitHub Q&A on this topic </discussions/73#discussioncomment-6682260>`.