forked from kito-cheng/dmtcp-android
-
Notifications
You must be signed in to change notification settings - Fork 2
/
QUICK-START
418 lines (365 loc) · 20.1 KB
/
QUICK-START
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
Overview of DMTCP (Distributed MultiThreaded Checkpointing)
CONCEPTS:
DMTCP Checkpoint/Restart allows one to transparently checkpoint to disk
a distributed computation. It works under Linux, with no modifications
to the Linux kernel nor to the application binaries. It can be used by
unprivileged users (no root privilege needed). One can later restart
from a checkpoint, or even migrate the processes by moving the checkpoint
files to another host prior to restarting.
There is one DMTCP coordinator for each computation that you wish
to checkpoint. By specifying --host and --port (or the environment
variables DMTCP_HOST and DMTCP_PORT), you can add a process
to a coordinator different from the default coordinator. If you don't
specify, the default coordinator is always at (localhost, 7779).
A DMTCP coordinator process is started on one host. Application binaries
are started under the dmtcp_checkpoint command, causing them to connect
to the coordinator upon startup. As threads are spawned, child processes
are forked, remote processes are spawned via ssh, libraries are dynamically
loaded, DMTCP transparently and automatically tracks them.
By default, DMTCP uses gzip to compress the checkpoint images. This can
be turned off (dmtcp_checkpoint --no-gzip ; or setting an
environment variable to 0: DMTCP_GZIP=0). This will be faster, and if
your memory is dominated by incompressible data, this can be helpful.
Gzip can add seconds for large checkpoint images. Typically, checkpoint
and restart is less than one second without gzip.
A DMTCP checkpoint image includes any libraries (.so files) that it may
have been using. This strategy is used for greater portability of
the checkpoint images --- and in some cases, it even allows migration of
the checkpoint images (and hence, processes) to hosts with different
Linux distributions, different Linux kernels, etc.
To run a program with checkpointing:
1) Run dmtcp_coordinator in a separate terminal/window
bin/dmtcp_coordinator
2) In separate terminal(s), replace each command(s)
with "dmtcp_checkpoint [command]"
bin/dmtcp_checkpoint ./a.out
3) To checkpoint, type 'c'<return> into dmtcp_coordinator
[ In dmtcp_coordinator window:
h<return> for help,
c<return> for checkpoint,
l<return> for list of processes to be checkpointed,
k<return> to kill processes to be checkpointed,
q<return> to kill processes to be checkpointed and quit the coordinator.]
4) RESTART:
Creating a checkpoint causes the dmtcp_coordinator to write
a script, dmtcp_restart_script.sh, along with a
checkpoint file (file type: .dmtcp) for each client process.
The simplest way to restart a previously checkpointed computation is:
./bin/dmtcp_restart_script.sh
[ ./dmtcp_restart_script.sh usually works "as is", but it can be edited ]
[ Alternatively, if all processes were on the same processor,
and there were no .dmtcp files prior to this checkpoint: ]
./bin/dmtcp_restart ckpt_*.dmtcp
============================================
CONVENIENCE COMMANDS AND DEBUGGING RESTARTED PROCESSES:
# Help exists:
bin/dmtcp_coordinator --help ; bin/dmtcp_checkpoint --help ;
bin/dmtcp_command --help, etc.
# Automatically start a coordinator in background
bin/dmtcp_checkpoint ./a.out &
# Checkpoint all processes of the default coordinator
bin/dmtcp_command --checkpoint
# Kill a.out, and optionally kill coordinator process
bin/dmtcp_command --kill
# Kill a.out, and optionally kill coordinator process
bin/dmtcp_command --quit
# Restart directly from local checkpoint images (.dmtcp files)
./dmtcp_restart_script.sh
# Or else, directly restart from the ckpt images in the current directory.
# (Be sure there are no old ckpt_a.out_*.dmtcp files.
# Ensure that the restarted process is running, and not suspended.)
bin/dmtcp_restart ckpt_a.out_*.dmtcp &
# Have gdb attach to a restarted process, and debug
# NOTE: You must specify 'mtcp_restart', not 'dmtcp_restart'
gdb ./a.out `pgrep -n MTCP`
# force a.out to exit any low level libraries and return to a known location
# set a breakpoint on a common function and continue:
(gdb) break write
(gdb) continue
============================================
COMMAND-LINE OPTIONS:
`dmtcp_checkpoint', `dmtcp_command', and 'dmtcp_restart' print
their options when run with no command-line arguments. `dmtcp_coordinator'
offers help when run (Type 'h<return>' for help.).
============================================
OPTIONS THROUGH ENVIRONMENT VARIABLES:
dmtcp_coordinator:
DMTCP_CHECKPOINT_INTERVAL=<time in seconds> (default: 0, disabled)
DMTCP_PORT=<coordinator listener port> (default: 7779)
DMTCP_CHECKPOINT_DIR=<where restart script is written> (default: ./)
DMTCP_TMPDIR=<where temporary files are written>
(default: env var TMPDIR or /tmp)
dmtcp_checkpoint / dmtcp_restart:
DMTCP_HOST = <hostname where coordinator is running> (default: localhost)
DMTCP_PORT = <coordinator listener port> (default: 7779)
DMTCP_GZIP = <0: disable compression of checkpoint image>
(default: 1, compression enabled)
DMTCP_CHECKPOINT_DIR = <location to store checkpoints> (default: ./)
DMTCP_SIGCKPT = <internal signal number> (default: 12 = SIGUSR2)
DMTCP_TMPDIR = <where temporary files are written>
(default: env var TMPDIR or /tmp)
dmtcp_command:
DMTCP_HOST = <hostname where coordinator is running> (default: localhost)
DMTCP_PORT = <coordinator listener port> (default: 7779)
Application-defined hook functions: called by DMTCP if defined
User code containing these functions and linked with libdmtcpaware.so
must be compiled with
-Wl,-export-dynamic under gcc/g++ or they won't be invoked.
If linked with dmtcpaware.a, no special compilation flags are needed.
For a libdmtcpaware.a example, do: cd test; rm dmtcpaware1; make dmtcpaware1
For example source code, see test/dmtcpaware[123].c
Application-defined hook functions are also available at the MTCP level
For an example, see mtcp/testmtcp.c, and try: cd mtcp ; make check
void mtcpHookPreCheckpoint(void);
void mtcpHookPostCheckpoint(void);
void mtcpHookRestart(void);
User-defined plugin modules may be added to DMTCP. For examples,
see the "test/plugin" directory of the source distribution.
============================================
SHORT NOTES:
1. A restarted process sees the shared libraries and environment variables
that existed prior to checkpoint. These are contained in the .dmtcp
checkpoint file.
2. At restart time, one can choose either to use the original
dmtcp_coordinator or else to start a new coordinator. Each process
restarted by the dmtcp_restart command needs to know the host and port
used by dmtcp_coordinator. These default to localhost and port 7779.
The coordinator can be specified to use port 0, in which case the
coordinator chooses arbitrary port, and prints it to stdout.
Setting DMTCP_PORT in the environment seen by the four main commands
(dmtcp_coordinator, dmtcp_checkpoint, dmtcp_restart and dmtcp_command)
will override the default port. Similarly, setting DMTCP_HOST for
dmtcp_checkpoint and dmtcp_restart is needed if they start on
a different host than that of the coordinator.
3. If your application has only a single process (single- or
multi-threaded), then you can also directly use the software in
the mtcp subdirectory (single-process layer) without the upper
layer in the dmtcp subdirectory. This may be convenient for
customizing the source code for your own application.
4. In order to enable various types of debugging, do:
A. To enable debug statements for DMTCP only (related to multi-process
communication), configure with: ./configure --enable-debug
(or './configure --help', in general)
--enable-debug both prints to stderr and writes files. This both
prints to stderr and writes files
$DMTCP_TMPDIR/dmtcp-$USER@$HOST/jassertlog.*
where $DMTCP_TMPDIR is /tmp by default on most distributions.
In reading this, it's useful to know that
DMTCP sets up barriers so that all processes proceed to the
following states together during checkpoint: RUNNING, SUSPENDED,
FD_LEADER_ELECTION, DRAINED, CHECKPOINTED, REFILLED, RUNNING.
B. If debugging MTCP (single-process layer) from within DMTCP, then:
a. uncomment the line:
CFLAGS += -O0 -g -DDMTCP_DEBUG -DTIMING -Wall
b. Then: (cd mtcp; make clean); make
C. To enable debug statements from MTCP (standalone mode),
do: In mtcp/Makefile, uncomment the line:
CFLAGS = -O0 -g -DDEBUG -DTIMING -Wall
Also, comment out the line: CFLAGS = -O0 -g
Then: (cd mtcp; make clean); make
D. If debugging: dmtcp_checkpoint a.out
and you wish to attach to a.out when it starts, then
a. Set the environment variable MTCP_INIT_PAUSE
mtcp/mtcp.c:mtcp_init() will pause 15 seconds.
b. dmtcp_checkpoint a.out &
c. gdb a.out `pgrep -n a.out` [During the 15 second pause.]
d. The usual gdb commands should be available to debug
a.out/libmtcp.so/dmtcphijack.so
5. It often works to migrate processes by moving the checkpoint files to
another host and editing dmtcp_checkpoint_restart.sh prior to
restarting. Whether it works is affected by how different are the
corresponding versions for the kernel and glibc.
6. Checkpoint is implemented by sending a signal to each user thread.
As with all well-written code, your system calls should be prepared
for an error return of EINTR (interrupted, due to a simultaneous
checkpoint invocation or other kernel activity), in which case you
can call the system call again.
7. See comment in code before mtcp/mtcp_restart_nolibc.c:readmemoryareas()
for specific handling of mapping of memory objects via mmap:
MAP_PRIVATE, MAP_SHARED, MAP_ANONYMOUS
Heuristically, if a memory area is mapped to a file for which user has
only read permission, then a restarted process uses the most recent
file. If a memory area is mapped to a file with write or execute
permission, the pre-checkpoint memory contents is copied back into
memory area.
8. For developers, mtcp/readmtcp is useful for debugging checkpoint
images. Run it without arguments for a usage message.
9. dmtcpaware exists for programs that wish to directly talk to the
dmtcp_coordinator, without the intervention of a human being.
See the test subdirectory for several example dmtcpaware programs.
10. utils/gdb-add-symbol-file may be a useful debugging tool. It computes
the arguments for the add-symbol-file command of gdb, to import
symbol information about a dynamic library. It is most useful in
combination with *-dbg Linux packages and prefix to dmtcp_checkpoint:
env LD_LIBRARY_PATH=/usr/lib/debug dmtcp_checkpoint ...
followed by 'attach' in gdb.
11. The particular combination of Ubuntu 8.10 (Intrepid) and
g++-4.3 with the default -O2 flag appears to have a bug.
(g++-4.3 decides to inline a certain function, and then fails
to compile because it decides that that function cannot be inlined.)
There are two easy workarounds. First, if make fails, then manually
re-execute the g++ compilation from the last line output by make,
but do not include "-O2". Alternatively, when configuring, use:
env CXXFLAGS=-O1 ./configure
12. A. Matlab should be invoked without graphics, and to be extra safe,
without the JVM. The -nodisplay and -nojvm flags for Matlab suffice:
bin/dmtcp_checkpoint matlab -nodisplay -nojvm
B. Older releases of Matlab (e.g. release 7.4) have several issues:
If you see a message about GLIBCXX-3.4 not found, you can either
use root privilege to replace Matlab's older libstdc++ by your
system's newer libstdc++ (back up Matlab's older libstdc++),
or else just re-configure and re-compile DMTCP as follows:
env CC=gcc-4.1 CXX=g++-4.1 ./configure
[ Also, modify mtcp/Makefile to use: CC=gcc-4.1 ]
make clean; make
13. How to checkpoint OpenMPI with DMTCP
Verify that mpirun works.
Verify dmtcp_{checkpoint,restart} commands are in your path:
ssh <REMOTE-HOST> dmtcp_checkpoint --help
If they are not in your path, adjust your shell initialization file
to extend your path.
Verify "ssh <REMOTE-HOST>" works without password otherwise
do the following:
ssh-keygen -t dsa [accept default values]
ssh-keygen -t rsa [accept default values]
cat ~/.ssh/id*.pub >> ~/.ssh/authorized_keys
make clean
make
make check
dmtcp_checkpoint mpirun ./hello_mpi
dmtcp_command --checkpoint
./dmtcp_restart_script.sh
DMTCP uses SIGUSR2 as default and so do older versions of OpenMPI.
If you have an older version (e.g < 1.3), try choosing a different
value of SIGNUM for DMTCP as follows:
dmtcp_checkpoint --mtcp-checkpoint-signal <SIGNUM> mpirun ./hello_mpi
14. Using DMTCP with X-Windows:
Note that this method does not work with X extensions like OpenGL.
If someone wishes to extend this method to OpenGL, we have some
ideas for an approach that we can share. Also, this method does
not currently successfully checkpoint an xterm, for reasons that
we do not fully understand. We will look further into this later
when time and resources permit.
Install TightVNC (either as a package from your Linux distro,
or at: http://www.tightvnc.com/
with installation instructions at:
http://www.tightvnc.com/doc/unix/README.txt
If the server fails to start, you may need to specify the location of
fonts on your system. Do this by editing the "vncserver" Perl script
(which you put in your path above). Modify the $fontPath variable
to point to your font directories. For example, I listed all of the
subdirectories of /usr/share/fonts/ in the fontPath.
The processes started up automatically by the VNC server are listed in
the ~/.vnc/xstartup file. Use the following as your ~/.vnc/xstartup,
where we use the blackbox window manager and an x_app application
as an example:
#!/bin/csh
blackbox &
x_app
You should test that you can use the vncserver and vncviewer now.
This example uses desktop number 1:
vncserver :1
vncviewer localhost:1
# Kill vncviewer window manually, and then:
vncserver -kill :1
Make sure the executables dmtcp_checkpoint, dmtcp_coordinator,
dmtcp_restart, and dmtcp_command are in your path.
Note that if the VNC server is killed without using the
"vncserver -kill", there will be some temporary files left over that
prevent the server from restarting. If this occurs, remove them:
rm -rf /tmp/.X1-lock /tmp/.X11-unix/X1
where X1 corresponds to starting the server on port 1.
Now, start the VNC server under checkpointing control:
dmtcp_checkpoint vncserver :1
Use the VNC viewer to view your x_app application in the blackbox
window manager:
vncviewer localhost:1
Before checkpointing, close any xterm windows. Also, close
the vncviewer itself. They can be reopened again after
the checkpoint has completed.
[Optional] To verify that vncserver is running under checkpoint control:
dmtcp_command h
dmtcp_command s
To checkpoint the VNC server, x_app, and any other processes running
under the VNC server, remove any old checkpoint files, and type:
rm -f ckpt_*.dmtcp
dmtcp_command --checkpoint
This creates a file of the form ckpt_*.dmtcp for each process being
checkpointed. To kill the vncviewer and restart,
use the restart script:
vncserver -kill :1
# This script assumes dmtcp_restart is in your path. If not,
# modify the script to replace dmtcp_restart by a full path to it.
./dmtcp_restart_script.sh
Alternatively, you may prefer to directly use the dmtcp_restart command:
vncserver -kill :1
dmtcp_restart ckpt_*.dmtcp
Note: if checkpointing doesn't fully complete, make sure you're not out
of disk space, and that there are no other file system problems.
15. For Mandriva Linux, and some others, you will need to ensure that the
packages 'patch', and 'linux-userspace-headers'
are installed in order to build DMTCP.
For Ubuntu/Debian Linux, ensure that the
packages 'patch' and 'linux-libc-dev' are installed.
For OpenSuse Linux, ensure that the
packages 'patch' and 'linux-kernel-headers'
16. By default in DMTCP, successive checkpoints of the same process
write to the same checkpoint image filename. If you prefer that
successive checkpoint be written to distinct filenames, then use:
./configure --enable-unique-checkpoint-filenames
17. DMTCP continues to use the original pid (process id), tid (thread id),
etc., even on restart from a checkpoint image. In this last
case, your program will see the _original pid_, and not the
current pid. At this time, a restarted process will appear
within the "ps" command under the program name "mtcp_restart".
18. Certain applications, such as some shells, vim, etc., try to
recognize mouse events from the X11 windows system. While DMTCP
successfully checkpoints and restarts these applications, it does so
by disabling the connection to X11. Mouse events are not recognized.
19. Support for incremental and differential checkpoint using the HBICT
package at http://hbict.sourceforge.net/projects/hbict/ .
HBICT (Hash Based Incremental Checkpointing Tool) provides DMTCP
support for delta-compression (relative to the previous checkpoint)
which is then additionally compressed using gzip. To enable it:
1) Download and install HBICT somewhere in your PATH. For example,
to test it in a single user's account:
$ tar zxvf hbict-1.0.tar.gz; cd hbict-1.0; ./configure; make
$ export PATH=$PWD/src:$PATH
To see the options of 'hbict', execute:
$ hbict --help
Note, in particular, the '-r' option to create a new full checkpoint
from the existing delta-compressed checkpoint files.
2) In the DMTCP directory, configure and re-make DMTCP for HBICT:
$ ./configure --enable-delta-compression; make clean; make
3) The --no-hbict and --no-gzip options of dmtcp_checkpoint
will control what type of compression is used.
a. 'dmtcp_checkpoint <my_prog>' causes successive checkpoints to be
delta-compressed relative to previous checkpoints (HBICT
compression) and then also compressed with gzip.
b. 'dmtcp_checkpoint --no-gzip <my_prog>' causes successive
checkpoints to be delta-compressed relative to previous checkpoints
(using HBICT compression).
c. 'dmtcp_checkpoint --no-hbict <my_prog>' causes gzipped checkpoints
to be created with no delta-compression.
d. 'dmtcp_checkpoint --no-hbict --no-gzip <my_prog>' disables all
compression.
If delta-compression is used you'll see the several checkpoint files in
your DMTCP_CHECKPOINT_DIR as in the following example using
HBICT+gzip compression:
$ dmtcp_checkpoint test/dmtcp1
$ ls -1 -sh
4,0K ckpt_dmtcp1_6cbb52b0-12935-4ddcf7a0.dmtcp
1,8M ckpt_dmtcp1_6cbb52b0-12935-4ddcf7a0.hbict.0
56K ckpt_dmtcp1_6cbb52b0-12935-4ddcf7a0.hbict.1
52K ckpt_dmtcp1_6cbb52b0-12935-4ddcf7a0.hbict.2
...
In this example, the size of the delta-compressed checkpoints are
32 times smaller, since test/dmtcp1 is mostly unchanging text (code),
with little data to change. The actualy delta-compression ratio
depends strongly on the particular application.
4) To restart the application you'll need the file
ckpt_dmtcp1_6cbb52b0-12935-4ddcf7a0.dmtcp, along with all the
*.hbict.N files to be present in the same directory. Then execute:
$ dmtcp_restart ckpt_dmtcp1_6cbb52b0-12935-4ddcf7a0.dmtcp
and the *.hbict.N files will automaticaly be discovered and used
by the HBICT tool.