-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmemo.txt
1705 lines (1461 loc) · 71.4 KB
/
memo.txt
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
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Delete:
C-S-backspace
Mark:
C-@
C-u C-@
C-x h
Numeric Commands
M-g M-g / M-g g
M-1 M-0 M-f
M-- 3 M-c
Movements:
M-m
M-a M-e
M-< M->
C-M-a C-M-e
C-M-f C-M-b
C-M-d C-M-u
M-r
C-M-v
C-u M-g M-g
Search:
M-s w
C-r C-r
C-a
C-e
M-f or M-left
M-b or M-right
M-<
M->
C-n
C-p
C-v
M-v
C-l
M-g g
M-g n
M-g p
C-s
C-r
M-%
C-enter
C-M-n???
C-o
C-j
C-m
C-;
M-;
M-d
M-backspace
C-k
C-S-backspace
C-x C-o
C-space???
C-x h
M-S-left select forward by words
M-S-right select backward by words
C-w
M-w
C-y
C-g
C-x C-l
C-x C-u
C-x C-f
C-x C-k
C-x C-s
C-s C-w
C-x b
C-x o
C-x 0
C-x 1
C-x 2
C-x 3
C-x 4
------------
M-up
M-down
M-S-up copy current line and paste to previous line
M-S-down copy current line and paste to next line
M-click
M-⌘-down multi-cursor
M-⌘-up
S-⌘-L
C-M-left
C-M-right
S-⌘-l
⌘-D
M-⌘-up
M-⌘-down
C-minus
S-⌘-\ jump to end or begin of a bracelet pair
M-⌘-left
M-⌘-right
C-single quote
M-x
C-M-space
FFI:
1. build.rs call cc and define library name;
2. add link attribute with the library name to the begining of the extern function definition block in Rust code;
3. add the extern function definition in a C header file.
Fuse Documentation
http://libfuse.github.io/doxygen/index.html
Fuse ABI
http://man7.org/linux/man-pages/man4/fuse.4.html
https://blog.csdn.net/weixin_34372728/article/details/91949774
from Zhi-Hu
https://zhuanlan.zhihu.com/p/68085075
from kernel doc:
The filesystem type given to mount(2) can be "fuse"
This is the usual way to mount a FUSE filesystem.
The first argument of the mount system call may contain an arbitrary string, which is not interpreted by the kernel.
There’s a control filesystem for FUSE, which can be mounted by:
mount -t fusectl none /sys/fs/fuse/connections
The userspace filesystem may ignore the INTERRUPT requests entirely, or may honor them by sending a reply to the original request, with the error set to EINTR.
INTERRUPT request handling
from osxfuse code
if (mo->auto_unmount) {
/* Tell the caller to fallback to fusermount because
auto-unmount does not work otherwise. */
return -2;
}
from Zero Copy article, about sendfile need file leasing to handle truncate
You are probably wondering what happens if another process truncates the file we are transmitting with the sendfile system call. If we don't register any signal handlers, the sendfile call simply returns with the number of bytes it transferred before it got interrupted, and the errno will be set to success.
If we get a lease from the kernel on the file before we call sendfile, however, the behavior and the return status are exactly the same. We also get the RT_SIGNAL_LEASE signal before the sendfile call returns.
from book
LRU/2
Radix优先搜索树lib/radix-tree.c
address_space_operation fs/ext3/inode.c
Directory enties stored in B+tree
B+tree in Rust?
tmpfs?
the ideal situation is the VM page size and the file system block size are equal
managing free space on a disk using bitmap
the number of blocks in an allocation group to be a multiple of the number of blocks mapped by a bitmap block, allocation group size would be 8192 blocks, the maximum allocation group size is always 65,536
log directory changes
The last accessed time is expensive to maintain, and in general the last modified time is sufficient
Drawback of extent: Because each block run in the direct and indirect blocks can map a variable amount of the file data, we must always search linearly through them
BFS uses the spare area of the i-node disk block to store small attributes
the list of attributes is just a directory, and the individual attributes are really just files
Using B+trees to store directories was the most attractive choice for BFS, the key is the name and the value is the i-node address
store the list of available indices as a “hidden” directory, the superblock also contains the i- node address of the index directory, indices and directories are identical
The attribute directory of a file is similar to a regular directory. Programs can open it and iterate through it to enumerate all the attributes of a file
The links between nodes in a B-tree are simply the offsets in the file of the other nodes
prefix B+tree for sring keys
Placing directory data and file i-nodes near each other can produce a very large speed boost because when one is needed, so is the other
The primary item that an allocation policy has control over is file data
preallocates 64K of space for the file when it is first written or when it is grown
A write to a single block on a disk is an indivisible (i.e., atomic) event
the journal always ignores partially com- pleted transactions when examining the log
Not only does journaling not store user data in the log, it cannot
The slowdown introduced by buffering only one transaction is significant enough that most file systems prefer to offer improved throughput instead of better consistency guarantees
With a single log, all transactions must lock access to the log before making modifications. A single log effectively forces the file system into a single-threaded model for updates
cache use hash table, drop cache use LRU
flush multiple dirty cache blocks at the same time
read 32K ahead on a cache miss
direct I/O scatter/gather I/O to bypass cache
hit-under-miss
the journal needs to know when each block is flushed from the cache, this is achieved with a callback function.
when the cache sets a callback for a block, the cache clones the block in its current state
Any I/O that is 64K in size or larger bypasses the cache
the percentage of the raw disk bandwidth that the file system achieves
tests used were IOZone and lmbench lat_fs
archiving and unarchiving large (10–20 MB) archives
compiling a library of source files
database package, video capture
PostMark
DMA in user space?
Make liberal use of runtime consistency checks
cross-checking
Magic number
APUE
Atomic IO: pread, pwrite, open(O_CREAT|O_EXCL), dup, dup2
O_ACCMODE, O_RDONLY, O_WRONLY, O_RDWR
ext2 don't really implement O_SYNC
_GNU_SOURCE for S_ISSOCK on Linux
S_ISUID, S_ISGID, S_ISVTX for st_mode
新建文件,要求对所在目录有写和执行权限
删除文件,要求对所在目录有写和执行权限,对被删文件没有权限要求
新文件的UID为进程的EUID,新文件的GID可以是进程的EGID也可以是所在目录的GID(要求目录S_ISGID,但新文件不会有S_ISGID)
_POSIX_CHOWN_RESTRICTION不允许chown,S_ISVTX不支持, 空洞不支持(truncate,lseek),硬链接link不支持,打开的文件或目录不能删除
BUFSIZE,
inode里不存文件名,目录项里存文件名和ino,NAME_MAX,PATH_MAX
被中断后自动重启的系统调用:ioctl、read、readv、write、writev、wait、waitpid
信号处理函数调用不可重入函数,如malloc,结果不可预期
信号处理函数唯一可以改变的是sig_atomic_t变量
fork之前改变对信号的配置,如忽略、阻塞、回调等
尽量少系统调用,写少量数据的话,复制到一个buffer调用write一次比writev从多个iov写要快
mmap for read?
TODO:
use Type for argument and convert to FileType with type check
read only mount and check
concurrent map and multi-thread
lru/2 cache and cache aging
maintains lookup count by create mknod, mkdir, lookup, forget
unlink, rmdir, rename deffered deletion
store modified attribute to disk?
zero copy
cache partial file content
Concurrency Tips:
use drop explicitly
std::alloc::handle_alloc_error for OOM
T: Sync if &T: Send
Sync + Send is = thread-safe
// Rust malloc
data: Box::into_raw(boxed_data),
let node = Box::into_raw(Box::new(Node::default()));
// Rust malloc
let mut data: Vec<Option<T>> = Vec::with_capacity(capacity);
for _ in 0..capacity {
data.push(None);
}
let raw_data = (&mut data).as_mut_ptr();
mem::forget(data);
// Buffer IO
BufReader and BufWriter
// use thread builder not spawn
thread::Builder
// for_each avoid collect
for_each vs map
// Functional
inspect, filter_map, and_then, or_else, chain, zip, cycle, all, skip_while, take_while, step_by, position, sum, product
// Itertools
iter::empty, iter::once, iter::repeat
batching, chunks, tuples, cartesian_product
// lifetime bound
struct Ref<'a, T: 'a>(&'a T);
// errno to Err
Result::Err(toErrorCode(err))
// memoization pattern, cache pure function only
#[macro_use] extern crate cached;
cached!{
FIB;
fn fib(n: u64) -> u64 = {
if n == 0 || n == 1 { return n } fib(n-1) + fib(n-2)
} }
fn main() {
fib(30); //call 1, generates correct value and returns it
fib(30); //call 2, finds correct value and returns it
}
// side-effect hiding, lazy evaluation using Monad pattern
let notyet = LazyMonad::_return(()).bind(|x| x+2).bind(|y| y*3).bind(|z| format!("{}{}", z, z));
let nowdoit = notyet.apply(222);
// multi line string
r###" "###;
// TODO macro
todo!();
// use crate flame for profiling
fn main() {
flame::start("fn main");
thread::sleep(t);
flame::end("fn main");
flame::dump_html(&mut File::create("flame-graph.html").unwrap()).unwrap();
}
// Copy int to print macro
let my_int = 76_u32;
println!("{}", {my_int});
// Partial default initializatin
SomeOptions { foo: 42, ..Default::default() }
use Box::pin() combined with Pin::as_mut() for heap pinning instead of using stack pinning
recursive enum definitions must wrap the inner value in a container such as Box, otherwise the size would be infinite
if it's smaller than or equal to usize, copy, always; between usize and 10 times that size, it's probably better to copy
empty enumerations cannot be instantiated
use unwrap_or_else() instead of unwrap_or()
use sort_unstable() instead of sort()
BufWriter
include!(concat!(env!("OUT_DIR"), "/phf.rs"));
_ => unreachable!(),
void (*signal(int, void (*func)(int)))(int)
^? ^\ ^c ^z
INIT
STATFS
GETATTR
OPENDIR
LOOKUP
READDIR
RELEASEDIR
clap
slog
toml
cargo-fuzz
https://github.com/postmates/hopper
https://github.com/blt/hopper-fuzz
https://github.com/BurntSushi/quickcheck
https://github.com/rust-fuzz/afl.rs
https://github.com/bheisler/criterion.rs
# upload file to transfer.sh
curl --upload-file ./hello.txt https://transfer.sh/hello.txt
# for openconnect
https://www.alibabacloud.com/blog/how-to-set-up-an-openconnect-vpn-server_595185
# for rust
cat <<EOF >>~/.profile
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup # for rust components
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup # for rust-init
EOF
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup self uninstall
# Rust开发环境的setup
https://hoverbear.org/blog/setting-up-a-rust-devenv/
# Install Sogou PinYin
https://pinyin.sogou.com/linux/guide
sudo dpkg -i com.alibabainc.dingtalk_1.2.0.132_amd64.deb
sudo dpkg -r com.alibabainc.dingtalk
sudo dpkg -P com.alibabainc.dingtalk
# To check if packagename was installed, type:
dpkg -s <packagename>
# You can also use dpkg-query that has a neater output for your purpose, and accepts wild cards, too.
dpkg-query -l <packagename>
# To find what package owns the command, try:
dpkg -S `which <command>`
# Check package version
apt list <packagename>
# show installed packages
apt-mark showauto
apt-mark showmanual
# mark a package as auto installed
apt-mark auto libibverbs-dev
# to search
apt-cache search XXXXX
# to list
apt list --installed
dpkg -l
snap list
# to uninstall
sudo apt remove package_name_1 package_name_2
sudo apt purge package_name # also remove config files
sudo apt autoremove # after remove or purge, autoremove dependencies
sudo snap remove package_name
# for cc
sudo apt install build-essential
# for all performance monitoring tools
sudo apt-get install sysstat linux-tools-common linux-tools-$(uname -r) iproute2 # msr-tools: for x86 only
sudo snap install bcc bpftrace bpfcc-tools
# for sccache
sudo apt install pkg-config libssl-dev
cargo install sccache
export RUSTC_WRAPPER=sccache
# for go
go build -o bin/main main.go
# for shadowsocks
sudo apt install shadowsocks-libev
sudo vim /etc/shadowsocks-libev/config.json
sudo systemctl disable/enable/restart shadowsocks-libev
cat <<EOF >/etc/shadowsocks-libev/config.json
{
"server":["129.159.42.23"],
"mode":"tcp_and_udp",
"server_port":28388,
"local_port":1080,
"password":"gibson.ovation@gmail.com",
"timeout":60,
"method":"xchacha20-ietf-poly1305"
}
EOF
# run iptables to allow ingress to Oracle cloud vm
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 28388 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p udp --dport 28388 -j ACCEPT
cat <<EOF >~/.cargo/config
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
EOF
rustc -C opt-level=3 data_race02.rs
rustc -O -g main.rs -o <output-program-name> # -O for release build, -g for debug info
rustc -C rpath # look for dynamic libraries
valgrind --tool=memcheck target/x86_64-unknown-linux-gnu/debug/hello_world
valgrind --tool=massif target/x86_64-unknown-linux-gnu/debug/hello_world
valgrind --tool=cachegrind --branch_sim=yes target/x86_64-unknown-linux-gnu/debug/hello_world
cg_annotate cachegrind.out
valgrind --tool=helgrind --history-level=full --log-file="results.txt" ./data_race00
valgrind --tool=callgrind --separate-threads=yes ./data_race00
valgrind --tool=callgrind --simulate-cache=yes --dump-instr=yes --collect-jumps=yes ./data_race00
callgrind_annotate --auto=yes callgrind.out.$pid
callgrind_annotate --auto=yes --show=D2mr --sort=D2mr
qcachegrind # kcachegrind
python gprof2dot.py -f callgrind -o <output>.dot callgrind.out.<pid>
dot -Tpng <output>.dot -o <DocName>.png
valgrind --tool=drd --exclusive-threshold=10 ./data_race00
# oprofile # sudo apt install oprofile
operf
opannotate oprofile_data
man syscalls # Linux
sudo dtrace -l -v -n 'syscall:::entry' # MacOS
sudo dtrace -qn 'syscall::write:entry, syscall::sendto:entry /pid == $target/ { printf("(%d) %s %s", pid, probefunc, copyinstr(arg1)); }' -p $SERVER_PID
sudo filebyproc.d
sudo dtrace -n 'syscall:::entry /pid==$target/ {}' -c "cmd"
sudo dtruss -f -p pid # pid can be a shell `echo $$`
sudo dtruss -f -d -eo -p 571 # print relative time, elapsed time, CPU time
sudo dtruss -f -a -p 571 # print relative time, elapsed time, CPU time
sudo dtruss -n "process name" hfsslower.d # track by process name
sudo lockstat -C "cmd" &> lockstat.log
sudo execsnoop
sudo fs_usage | grep -i open
sudo filebyproc.d
sudo opensnoop
cat /proc/cpuinfo
cat /proc/meminfo
cat /proc/kallsyms # kernel functions
# tcp_retransmit_skb # kernel function, tcp retransmit
# tcp_cleanup_rbuf # kernel function
# __alloc_fd
man syscall
# Arch/ABI arg1 arg2 arg3 arg4 arg5 arg6 arg7 Notes
# x86-64 rdi rsi rdx r10 r8 r9
cat /sys/kernel/debug/tracing/events/block/block_rq_insert/format
sudo ls /sys/kernel/debug/tracing # ftrace, or maybe kprobe
# eBPF bcc tools, installed in /sbin (/usr/sbin in Ubuntu 18.04) with a -bpfcc extension.
sudo apt-get install bpfcc-tools linux-headers-$(uname -r)
funccount-bpfcc '*alloc*fd*' # count kernel function calls with name matching
funccount-bpfcc -i 1 '*icmp*' # count every second
funccount-bpfcc -i 1 '*tcp*'
funccount-bpfcc -i 1 'bio_*'
funcslower-bpfcc 'icmp_rcv' 2 # tracing function calls slower than 2 ms
perf probe -n -v 'icmp_out_count net->ifindex' # -n: dry run, -v: verbose, find out kernel function and argument from kernel debuginfo
cat /proc/kallsyms | grep " T " # list call kprobe enabled kernel functions
trace-bpfcc do_sys_open # trace a kernel function
trace-bpfcc ksys_read
trace-bpfcc -KU __alloc_fd # trace who's calling this kernel function
tcplife-bpfcc # `tcplife-bpfcc -L 22`: show connection to this local port, trace TCP sessions with PID, bytes, and duration
trace-bpfcc # `trace-bpfcc 'sys_read (arg3 > 20000) "read %d bytes", arg3'`: reads over 20000 bytes
argdist-bpfcc # `argdist-bpfcc -H 'p::tcp_cleanup_rbuf(struct sock *sk, int copied):int:copied'`: histogram of tcp_cleanup_rbuf() copied argument
tcptop-bpfcc
ttysnoop-bpfcc /dev/pts/1 # use `tty` to find out which terminal, and then use `ttysnoop-bpfcc` to find out what's doing in the terminal
time $COMMAND # find out the execution time of a command, splits into real, user, system times
perf stat $COMMAND # profiling a command
perf stat -e block:block_rq_complete -a sleep 10 # trace a counter of all CPU for 10 seconds
perf stat -e cycles,instructions,cache-references,cache-misses,bus-cycles -a -- sleep 10 # trace hardware
argdist-bpfcc -i 5 -C 'p::cap_capable():int:ctx->dx' # count of DX register when cap_capable is called for every 5 seconds
bpflist-bpfcc # display processes currently using BPF programs and maps
# Off-CPU flamegraph
sudo offcputime-bpfcc -uf > out.offcpustacks # -u: user threads only, -f: fold
./flamegraph.pl --color=io --countname=us --width=900 --title="Off-CPU Time Flame Graph: idle system" < out.offcpustacks > offcpu.svg
# PRELOAD=/path/to/my/malloc.so /bin/ls to specify customized libraries used by java, etc
# bcc/eBPF General Performance Checklist
1. execsnoop # `execsnoop-bpfcc -T`: find out which cmds are running, discover short-lived processes, -x/--fails: include failed exec()s
2. opensnoop # show what files being opened, -p PID: trace this PID only, -t TID: trace this TID only, -u UID: trace this UID only
3. ext4slower (...) # `ext4slower-bpfcc 1`: tracing ext4 operations slower than 1 ms, T as type: S for synchronized IO,
4. biolatency # `biolatency-bpfcc -mT 10 1`: find out multimodal disk I/O latency and outliers, -m: millisecond histogram, -T: include timestamp on output, for 10 seconds, run once
5. biosnoop # find out each disk IO life
6. cachestat
7. tcpconnect
8. tcpaccept
9. tcpretrans # retransmit in SYN SEQUENCE state is fine, but retransmit in ESTABLISHED, SYN SENT state means something strange, it might hit a backlog
10. gethostlatency # find out DNS latency issues system wide
11. runqlat # `runqlat-bpfcc 10 1` examine CPU scheduler run queue latency as a histogram, every 10 seconds, for once, CPU saturation, find out kernel scheduling issue
12. profile
# BPF
# for CPU
execsnoop-bpfcc -T # find out short-lived processes, or what's running behind a build process
ttysnoop-bpfcc /dev/pts/1 # use `tty` to find out which terminal, and then use `ttysnoop-bpfcc` to find out what's doing in the terminal
runqlat-bpfcc 10 1 # run queue latency, scheduling is very frequent, millions per second, BPF brings 70ns overhead each scheduling event
runqlat-bpfcc -m 5 # -m: millisecond histogram, run for every 5 seconds
runqlen-bpfcc 10 1 # run queue length, 99Hz sampling of queue length, much less overhead than runqlat-bpfcc
cpudist-bpfcc -p $PID 10 1 # show CPU time histogram of a process, for 10 seconds duration once
cpudist-bpfcc -p $(pidof CMD) # show CPU time histogram of a process, helps understand the context-switching characteristics of your application, it is these smaller context switch intervals that we should be worried about
# for Off-CPU
cpudist-bpfcc -O -p $(pidof CMD) # histogram of time intervals when some application thread was off the CPU waiting for something
offcputime-bpfcc -p $PID # collects stack traces whenever an application thread is blocked (switched off the CPU), and identifies the duration of time that blockage lasted
offcputime-bpfcc -f -u 30 # -f: output folded format, -u: print only user-mode stacks, for 30 seconds
offcputime-bpfcc -f -p $(pidof CMD) > folded-stacks && ./flamegraph.pl --color=io folded-stacks > offcpu.svg # generate off-cpu flamegraph
# for memory
memleak-bpfcc -p $PID # show the top 10 stacks sorted by oustanding allocations, allocations performed and not freed since the tool has attached to the process
ffaults.bt # file page faults
# for disk IO
# Limitation of biosnoop: if you use an encrypted filesystem, you may see the I/Os requests as occuring on behalf of dmcrypt.
biosnoop-bpfcc # instrumenting disk IO event life, start time, end time, duration, etc
biosnoop.bt # find out the actual I/O operations and their latencies
biolatency-bpfcc -mT 1 5 # histogram for disk IO latency, run for every 1 second, totally 5 times
biolatency.bt # histogram for disk IO latency
bitesize-bpfcc # histogram of disk IO size
biotop # find out which processes are doing block IO
stackcount-bpfcc -i 10 submit_bio # show the call stacks submitting these I/Os in the kernel, at 10 second intervals
# for FS
fileslower 1 # tracing sync read/writes slower than 1 ms, find out which files are writing, and which operations are taking a bit longer than others:
opensnoop-bpfcc # find out what files are being opened system wide
opensnoop-bpfcc -p $PID # find out what files are being opened by a process
ext4slower-bpfcc 1 # ext4 FS IO slower than 1ms
ext4slower-bpfcc 0 # all ext4 FS IO
ext4dist-bpfcc # histogram of latency for each type of FS operation, such as read, open, write, etc. summarizes the latency of Btrfs reads, writes, opens, and fsync operations into power-of-two buckets
cachestat-bpfcc # FS cache statistics
xfsslower-bpfcc 50 # find out XFS I/O slower than a threshold (variants for ext4, btrfs, zfs)
xfsdist-bpfcc 60 # show XFS I/O latency histograms, by operation
readahead.bt # show the histogram of how readahead populating the cache, like how many pages loaded by readahead will be read in 0~32ms?
echo 1 > /proc/sys/vm/drop_caches # to clear the file system cache
syncsnoop-bpfcc # tracepoint:syscalls:sys_enter_sync
# for interrupt
hardirqs-bpfcc 1 # summary of time spent servicing various interrupts, run for every second
# for network
tcptop-bpfcc # summarize TCP send/recv throughput by host
tcpconnect-bpfcc # outbound TCP connections, who I'm connecting to
tcpconnect-bpfcc -t # tracing tcp connection kernel function only, not tcp send or receive
tcpaccept-bpfcc # inbount TCP connections, who's connecting me
tcpretrans-bpfcc # TCP retransmit
gethostlatency-bpfcc # instrument the resolver library/DNS, show the DNS resolution latency
tcplife-bpfcc # show TCP session lifespans with connection details, MS: session duration in milliseconds
tcpsynbl.bt # show TCP SYN backlogs as histograms, backlog means kernel buffer some inbound sessions
# for tracing
bpftrace -e 'tracepoint:raw_syscalls:sys_enter { @[pid, comm] = count(); }' # show most called syscalls
funccount-bpfcc 'tcp_s*' # count native function calls (C, C++, Go, etc.)
funccount-bpfcc -i 1 '*icmp*' # count kernel function calls match icmp, run for every 1 second
funclatency-bpfcc icmp_out_count # show the latency histogram for this icmp_out_count function calls
funclatency-bpfcc -m "$(which node):*PerformGarbageCollection*" # get a latency histogram of a function in the Node binary, -u: microsecond histogram, -m: millisecond histogram
funcslower-bpfcc icmp_rcv 1 # show the function all to imcp_rcv slower than 1ms
trace-bpfcc icmp_out_count # find out who's calling this icmp_out_count function
trace-bpfcc -T -K 'icmp_out_count "#2 arg=%d" arg2' # output the detail of this icmp_out_count function, what's its second argument, -T: add time column, -K: output kernel stack trace
trace-bpfcc -I net/net_namespace.h 'icmp_out_count(struct net *net, unsigned char type) "net->ifindex=%d, type=%d", net->ifindex, arg2' # -I: include header for this icmp_out_count function definition
argdist-bpfcc -I net/net_namespace.h -i 10 -C 'p::icmp_out_count(struct net *net, unsigned char type):int:net->ifindex' # -I: include header, -i: run interval, -C: counter, -H: histogram
trace-bpfcc 'sys_read (arg3 > 20000) "read %d bytes", arg3' # trace the read syscall and print a message for reads >20000 bytes
argdist-bpfcc -H 'p::tcp_cleanup_rbuf(struct sock *sk, int copied):int:copied' # histogram of the copied argument of this tcp_cleanup_rbuf function
trace-bpfcc -T -K 'do_open_execat "fd=%d, fname=%s, flag=%d" arg1,arg2,arg3'
bpftrace -e 'profile:hz:99 /pid == 20071/ { @[ustack] = count(); }' > /tmp/fg_bp1.txt
syscount.bt -p $PID # find out all syscall events from a process
argdist-bpfcc -p $PID -H 'p::do_nanosleep(struct timespec *time):u64:time->tv_nsec' # histogram of the time->tv_nsec argument in this do_nanosleep function
argdist-bpfcc -p $PID -C 'p:c:open(char *filename):char*:filename' # count of different filename argument in this open function
argdist-bpfcc -p $PID -C 'r:c:open():int:$retval' # count of different return value of this open function
stackcount-bpfcc -p $PID c:malloc # count call stacks for malloc in PID
stackcount-bpfcc -p $(pgrep -n node) "u:$(which node):gc__start" # attaching to the gc__start probe
trace-bpfcc 'sys_setuid "uid=0x%x", arg1' 'r::sys_setuid "rc=%d", retval' # trace setuid call and return
trace-bpfcc '::sys_setuid "uid = %d", arg1' # trace setuid syscall, setuid is call when doing su, ssh
argdist-bpfcc -T 5 -i 5 -C 'p::__vfs_write(struct file *f):char*:f->f_path.dentry->d_name.name#writes' -C 'p::__vfs_read(struct file *f):char*:f->f_path.dentry->d_name.name#reads'
argdist-bpfcc -C 't:irq:irq_handler_entry():int:args->irq' # prints the number of times irq_handler_entry() is called, along with which interrupt was raised
# for dynamic tracing
trace-bpfcc 'c:malloc "size=%d", arg1' # trace the malloc function and show the memory allocation size argument
trace-bpfcc 'c:write "size=%s", arg2' # trace the write input buffer
trace-bpfcc 'c:read "size=%s", arg2' # trace the read input buffer
bpftrace -e 'kretprobe:sys_read { @bytes = hist(retval); }' # show the histogram of sys_read return size
# for USDT
calls # summarizes method calls
uflow # traces function entry and exit and prints a visual flow graph
ugc # traces garbage-collection events
uobjnew # prints summary statistics for new object allocations
uthreads # prints details on thread creation
ustat # a monitoring tool that pulls all of these together and displays their events with a top-like interface
bashreadline-bpfcc # find out what commands bash is running from all users
trace-bpfcc 'u:/lib/aarch64-linux-gnu/libc-2.31.so:memory_sbrk_more "%u", arg1' -T #
trace-bpfcc 'u:/lib/aarch64-linux-gnu/libpthread.so.0:pthread_start' # trace libpthread trace point pthread_start
trace-bpfcc -p $PID 'u:/opt/node/node:http__server__request "%s %s", arg5, arg6' # trace node.js node:http__server__request USDT event
trace-bpfcc 'u:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.77-1.b03.fc22.x86_64/jre/lib/amd64/server/libjvm.so:class__loaded "%s", arg1' # trace JDK class__loaded
argdist-bpfcc -C 'u:/usr/lib/.../libjvm.so:method__entry():char*:arg4' -T 5 # -T 5: top 5 counters
trace-bpfcc -o 'u:/usr/lib/.../libjvm.so:method__entry "%s.%s", arg2, arg4' 'u:/usr/lib/.../libjvm.so:method__return "%s.%s", arg2, arg4' # trace each method call and return in JVM
# for profiling
profile-bpfcc -F 997 -p $(pidof CMD)
profile-bpfcc -dF 99 30 | ./FlameGraph/flamegraph.pl > perf.svg # -d: insert delimiter between kernel/user stacks, -F: sample freequency, for 30 seconds
profile-bpfcc -f # profile CPU stack traces at a timed interval, -f: output in folded format for flame graphs
profile-bpfcc -F 99 -p $PID # java preserve frame pointer: -XX:+PreserveFramePointer -XX:+ExtendedDTraceProbes, java run in compiled mode after interpret 10 methods: -XX:CompileThreshold=10, JIT symbal table for perf /tmp/perf-PID.map, jmaps for java JIT symbal table
# list trace points
sudo bpftrace -l # list all the hardware, timer, kprobe and kernel static tracepoints by running
nm /path-to-binary # list all the uprobe tracepoints (function symbols) of an app or library by running
nm -n -a /usr/lib/libc-2.28.so # list symbols in file(s) (a.out by default), -a: display debugger-only symbols, -n: sort symbols numerically by address
tplist-bpfcc -l /path-to/binary # list all the USDT tracepoints of an app or library by running
/sys/kernel/debug/tracing/available_events # tracepoints
/sys/kernel/debug/tracing/available_filter_functions # kprobe functions
/sys/kernel/debug/tracing/available_tracers # tracers
sudo ls /sys/kernel/debug/tracing/events/ # inside this directory, *event-cateogry*/*event*/format show the tracepoint args
tplist-bpfcc -l ./$COMM/$LIB # list USDT probes in the specified library or executable
tplist-bpfcc -vv -l /lib/aarch64-linux-gnu/libpthread.so.0 '*lock*' # show USDT trace points and argument details in libpthread, matching *lock*
tplist-bpfcc -p $PID # list USDT probes in the specified process
tplist-bpfcc -l $LIB -vv '*server__request' # print out more details about the server__request probe
tplist-bpfcc -p $PID '*class*loaded' # show matched USDT trace points
bpftrace -l 'tracepoint:syscalls:sys_enter_*' # list probes
bpftrace -vl tracepoint:syscalls:sys_enter_openat # show tracepoint details, including args struct
perf list | grep -i hardware
perf list | grep Tracepoint # static kernel trace point
perf list | grep Tracepoint | grep block # block IO trace point
cat /proc/kallsyms | grep " T " | grep sys_read # kprobe symbals, all the kernel functions can be used in kprobe
perf list 'block:*' # static kernel trace point
# for MySQL
dbslower.py mysql -m 1000 # tracing MySQL queries slower than 1000 ms
mysqld_qslower-bpfcc $(pgrep mysqld) # find out MySQL slow queries
# for kernel
workq.bt # kernel work queue function execution times
# for VM
xenhyper.bt # count hypercalls from Xen PV guests
# for container
blkthrot.bt # count block I/O throttles by blk cgroup
# generate IO workload
dd if=/dev/zero of=/dev/null bs=1K count=1M
sha1sum /dev/zero
# for bpftrace
bpftrace -e 'kr:vfs_read { @ = hist(retval); }'
bpftrace -e 'kprobe:__iwl_dbg { printf("%s", str(arg4)); }'
bpftrace -e 't:block:block_rq_issue { @[args->rwbs] = count(); }' # rwbs: type field of block IO, R: # of read, WS: # of synchronuous write
bpftrace -e 't:block:block_rq_issue { @bytes[comm] = hist(args->bytes); }' # show histogram of the block IO size for each process
bpftrace -e 't:syscalls:sys_enter_open { printf("%s %s\n", comm, str(args->filename)) }' # files opened by process
bpftrace -e 't:syscalls:sys_exit_read { @[comm] = hist(args->ret) }' # read size distribution by process
bpftrace -e 'kprobe:vfs_* { @[func]++ }' # Count VFS calls
bpftrace -e 'k:vfs_read { @[tid] = nsecs } kr:vfs_read /@[tid]/ { @ns = hist(nsecs - @[tid]); delete(@tid) }’ # show vfs_read latency as a histogram
bpftrace -e 'uretprobe:bash:readline { printf(“%s\n”, str(retval)) }’ # Trace user-level function
# for bpftool
bpftool perf # show what BPF programs are running, and what events they are instrumenting
bpftool prog dump jit id $PID # list instructions/assembly for some running process
bpftool prog # show current running BPF programs details
bpftool prog dump xlated tag $TAG # dump byte code of a BPF program with TAG
bpftool prog dump jit tag $TAG # dump JIT code of a BPF program with TAG
bpftool map # show the currently used maps
bpftool map dump id $MAP_ID # show the details about a map with MAP_ID showed from `bpftool map`
perf stat -b BPF_TAG/ID/NAME # perf for BPF programs
IPC: instructions per cycle
LLC: last level cache or longest latency cache
PSI: pressure stole information that splits load average into CPU, memory and disk IO
MSR: module specific register
FlameScope: subsecond-offset heat map, for analyze variance, perturbations https://github.com/Netflix/flamescope
perf stat -e cs -a -p $PID -I 1000 # cs: context switch
perf trace -p $PID # do not use strace in production, use perf trace instead
nstat -s # replacement for netstat
slabtop # kernel use slab as allocator, show kernel memory usage
file /usr/lib/libc-2.28.so # show the details of a library, e.g. stripped or not
readelf -n $BINARY # check the stap debug section to find out USDT
nm -n -a /usr/lib/libc-2.28.so # list symbols in file(s) (a.out by default), -a: display debugger-only symbols, -n: sort symbols numerically by address
objdump -tT `which bash` | grep readline # uprobe find out a function of bash whose function name contains 'readline'
objdump -x ./tick | less # uprobe find out the USDT load address
# The maximum number of files that can be watched
cat <<EOF >>/etc/sysctl.conf
fs.inotify.max_user_watches=524288
EOF
sudo sysctl -p # reload sysctl.conf
sudo sysctl -w kernel.perf_event_paranoid=-1 # enable non-root user to use perf
perf stat --event task-clock,context-switches,page-faults,cycles,instructions,branches,branch-misses,cache-references,cache-misses ./data_race02
perf stat -a -d
perf trace
perf record -e cpu-clock -g -p pid
perf script -i perf.data &> perf.unfold
cat tmp.unfold | ~/Downloads/FlameGraph/stackcollapse-perf.pl | ~/Downloads/FlameGraph/flamegraph.pl > tmp.svg
perf stat -e 'ext4:*' -a
perf stat -e 'ext4:*' -a sleep 10
perf record -F 99 -a -g -- sleep 10 # -F: sample frequency in Hz, -a: for all CPU, -g: for call stacks or call graphs
perf record -g -F 997 -- ./primes # profile a program, -t: trace only a single thread within a process
perf report -n --stdio # show report in terminal
perf record -g dwarf # fix broken stacks
perf script
perf script > tmp.unfold
perf top # like top, but perf version top
perf annotate -i perf.data --stdio
perf record -e cycles:ppp
Utilization: busy time
Saturation: queue length or queued time
Error: easy to interprete
NOT INSTALLED: dstat, atop, pcstat
Packages: sysstat, procps, coreutils
iostat -x 1
netstat -s # protocal stat
netstat -i # interface stat
netstat -r # route table
netstat -p # process detail
netstat -c # continue listing
ss # socket stat
sar -n DEV 1 # check network IO, similar to dstat
strace -p `pgrep $PROCESS_NAME`
strace -p `pidof $PROCESS_NAME`
strace -e bpf,read,write,openat,perf_event_open,ioctl $COMMAND # trace multiple syscalls
pkill $PROCESS_NAME
uptime # load average, CPU saturation
htop
ps -ef f # show process tree
ps -eo user,sz,rss,minflt,majflt,pcpu,args
vmstat -Sm 1 # r: run queue length for CPU, swpd: swapping, so & si: swap ins and swap outs, non-zero means oom,
iostat -xmdz 1 # r/s: read per second, w/s write per second, rMB/s: read throughput, wMB/s: write throughput, avgqu-sz: average queue size, await: average wait time in millisecond for block device of disk IO, svctm: service time, average await time removes queuing time, %util: busy time percentage, %util>60% means IO issues
mpstat -P ALL 1 # look for unbalanced CPU, hot CPU
free -m # buffers: block device IO cache, cached: virtual page cache
strace -ttt -T -p $PROCESS_ID # -ttt: time(us) since epoch, -T: syscall time
strace -t -p $PROCESS_ID 2>&1 | head 100 # -t timestamp, only use strace to trace recent 100 syscalls
nicstat 1 # similar result format as iostat
pidstat -t 1 # per-thread break down for CPU usage
pidstat -d 1 # per-process block device IO
pidstat -u -p $(pidof server) 1 # -u: CPU usage, run for every second
swapon -s # swap device usage if enabled swap
lsof -iTCP -sTCP:ESTABLISHED # current active network connections
sar -n TCP,ETCP,DEV,EDEV 1 # System Activity Reporter, ETCP: TCP error, DEV: network interface device, EDEV: network interface device error, active: outbound connections, passive: inbound connections, retrans: re-transimit
ss -mop # socket stat, mem: buffer size
ss -i # rcv_space: receive space
iotop # block device I/O (disk) by process
slabtop # kernel slab allocator memory usage
pcstat $FILE_NAME # install from github, page cache residency in memory percengage by file
tiptop # PMC: performance measurement counter for hardware events, IPC: instructions per cycle, MISS: cache miss
# for both us and sy CPU usage high:
vmstat -> mpstat -> pidstat -> iostat -> sar
fio --name=seqwrite --rw=write --bs=128k --size=122374m # filesystem, disk IO banchmarking
arp -na
netstat -rn # route table
ip route get $IP_ADDRESS # route path for one IP
sudo route add -net 10.67.0.0/16 gw 192.168.120.254 # Linux
sudo route -n add -net 10.67.0.0/16 192.168.120.254 # MacOS
# perf profiling
perf record -F 99 -a -g -- sleep 30 # generate perf.data
perf script | ./stackcollapse-perf.pl |./flamegraph.pl > perf.svg # generate flame graph perf.svg
# perf tracing
perf record -e block:block_rq_complete -a sleep 10
perf script
sudo pstack pid
sudo gdb -p pid
lldb
(lldb) file <program path>
(lldb) apropos <keyword>
(lldb) command alias bfl breakpoint set -f %1 -l %2 # (lldb) bfl foo.c 12
(lldb) command unalias bfl
(lldb) file /Projects/Sketch/build/Debug/Sketch.app
(lldb) breakpoint [set|delete|clear|enable|disable|list]
(lldb) breakpoint delete 1
(lldb) breakpoint command add 1.1
Enter your debugger command(s). Type 'DONE' to end.
> bt
> DONE
(lldb) r c bt s n f
(lldb) process attach --pid <pid>
(lldb) process attach --name <process name> --waitfor
(lldb) thread until 100
(lldb) thread list
(lldb) thread backtrace
(lldb) thread backtrace all
(lldb) thread select 2
(lldb) thread return <RETURN EXPRESSION>
(lldb) frame variable --format x bar
(lldb) frame select --relative -3
(lldb) image list
vim -b Hello.class
:%!xxd -c 12 将当前文本转换为16进制格式,并每行显示12个字节
:%!xxd -r 将当前文件转换回文本格式
cargo install cargo-profiler
cargo profiler callgrind --bin ./target/debug/performance_profiling4 -n 10
cargo profiler cachegrind --bin ./target/debug/rsmat -n 10 --sort dr
cargo +nightly run --release --example hex -p stdsimd
cargo +nightly bench # run bench
cargo docs
echo "a 55" | nc -c -u 127.0.0.1 1990
sudo fuser -v -n tcp 22
fuser -v -m example.txt
Linux Perf Analysis in 60s
uptime # load averages
dmesg -T | tail # kernel errors
vmstat 1 # overall stats by time
mpstat -P ALL 1 # CPU balance
pidstat 1 # process usage
iostat -xmdz 1 # disk I/O
free -m # memory usage
sar -n DEV 1 # network I/O
sar -n TCP,ETCP 1 # TCP stats
top # check overview, but top cannot catch short-live process
# Ubuntu kernel update
# Downloads latest stable kernel from https://kernel.ubuntu.com/~kernel-ppa/mainline/
# The following two packages are needed:
# linux-image-*X.Y.Z*-generic_*.deb
# linux-modules-X.Y.Z*-generic_*.deb
sudo dpkg --install linux-*.deb
# Ubuntu install kernel headers
# Downloads kernel headers from https://kernel.ubuntu.com/~kernel-ppa/mainline/
# The following tow packages are needed:
# linux-headers-X.Y.Z*_all.deb
# linux-headers-X.Y.Z*-generic_*.deb
sudo dpkg --install linux-headers-*.deb
sudo -s # sudo -i
RUST_LOG=debug RUST_BACKTRACE=full
git fetch upstream
git checkout master
git rebase upstream/master
git config --global user.name "Pu Wang"
git config --global user.email "nicolas.weeks@gmail.com"
git config --global core.editor "vi"
git config --list
git remote add upstream git@github.com:datenlord/datenlord.git
git remote set-url origin git@git-repo:new-repository.git
git remote -v
git push origin --delete remoteBranchName
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global --unset http.proxy
git push --delete origin tagName
git tag -d tagName
# Git LFS
brew install git-lfs
sudo apt install git-lfs
git lfs install # run this cmd in a git versioned directory
git lfs track <LARGE FILE>
git add .gitattributes # 管理文件.gitattributes添加入git仓库
git lfs untrack <LARGE FILE>
git lfs uninstall
git rm --cached <LARGE FILE>
git add <LARGE FILE>
git add --renormalize .
ALL_PROXY=socks5://127.0.0.1:1080 git clone https://github.com/some/one.git
CARGO_HTTP_PROXY=socks5://127.0.0.1:1080 cargo build
sudo timedatectl set-timezone EST
timedatectl list-timezones
sudo timedatectl set-timezone America/Los_Angeles
timedatectl; ls -l /etc/localtime
# for wine and WeChat
sudo apt install wine winetricks
winecfg # set screen resolution to 240dpi
wine Downloads/WeChatSetUp.exe # to install WeChat
cd ~/.wine/drive_c/
winetricks # install fonts: corefonts, fakechinese, wenquanyi
cat <<EOF >/tmp/fonts.reg #
REGEDIT4
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink]
"Lucida Sans Unicode"="msyh.ttc"
"Microsoft Sans Serif"="msyh.ttc"
"MS Sans Serif"="msyh.ttc"
"Tahoma"="msyh.ttc"
"Tahoma Bold"="msyhbd.ttc"
"SimSun"="msyh.ttc"
"Arial"="msyh.ttc"
"Arial Black"="msyh.ttc"
EOF
# Add/Delete user
sudo useradd -m -s $(which bash) -G sudo pwang
sudo usermod -aG sudo pwang
sudo deluser --remove-home pwang
wine regedit /tmp/fonts.reg
winetricks settings fontsmooth=rgb
# desktop shortcut
~/.config/menus/applications-merged/
/usr/share/applications/
# for zsh
sudo apt install zsh
chsh -s `which zsh` # set zsh as default shell
# for omz
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
cat <<EOF >> ~/.zshrc
. ~/.bash_aliases
source <(kubectl completion zsh)
EOF
# for Merlin
service httpd_restart
service start_httpd
# for snap
snap install vlc // installed with --classic flag to access files outside user’s home directory
snap search/find vlc
snap list
snap remove vlc
# for VSCode
sudo apt install ./code_1.48.2-1598353430_amd64\ \(1\).deb
sudo apt-get purge code
sudo snap install code --classic
# for IDEA
sudo snap install intellij-idea-community --classic
# run http server
python3 -m http.server
# install pip3
sudo apt install python3-pip
# install default java JDK
sudo apt install default-jdk
# Install golang
wget https://golang.org/dl/go1.15.5.linux-amd64.tar.gz
tar -C /usr/local -xzf go*.tar.gz
export PATH=$PATH:/usr/local/go/bin
# Install Docker
sudo apt install docker.io
sudo groupadd docker
sudo usermod -aG docker $USER
sudo systemctl restart docker
# re-login to make it effectively
sudo systemctl start docker
sudo service docker start
docker login # login to docker hub
docker system prune --volumes
# change Docker image folder
vi /etc/docker/daemon.json
{
"data-root": "/path/to/your/docker"
}
# change Docker registry source
vi /etc/docker/daemon.json
{
"registry-mirrors": [
"http://hub-mirror.c.163.com",
"https://mirror.ccs.tencentyun.com",
"https://docker.mirrors.ustc.edu.cn",
"https://cr.console.aliyun.com",
"https://registry.docker-cn.com"
]
}