| 1 | = Velvet & NGS = |
| 2 | |
| 3 | * [問題] Velvet 在處理 NGS (Next Generation Sequencing,新一代的定序技術)時,會遇到記憶體需求高達 1 TB的情形。解決方法可分為兩階段:(1) 使用單機的 CPU,使用 memcached 提供共享記憶體 (2) 完全 MPI 化。 |
| 4 | |
| 5 | == Stage 1 : 理解 Velvet 運算特性 == |
| 6 | |
| 7 | == [wiki:jazz/11-05-04 2011-05-04] == |
| 8 | |
| 9 | * [wiki:biocluster/Velvet Velvet 安裝紀錄(2009-11-11)] |
| 10 | * 測試 Velvet 1.1.03 (支援 OpenMP) |
| 11 | * 系統:Debian Squeeze |
| 12 | {{{ |
| 13 | ~$ sudo apt-get update; sudo apt-get upgrade; sudo apt-get dist-upgrade |
| 14 | ~$ sudo apt-get install build-essential |
| 15 | ~$ wget http://www.ebi.ac.uk/~zerbino/velvet/velvet_1.1.03.tgz |
| 16 | ~$ tar zxvf velvet_1.1.03.tgz |
| 17 | ~$ cd velvet_1.1.03 |
| 18 | ~/velvet_1.1.03$ make |
| 19 | ~/velvet_1.1.03$ ./velveth output 17 -fasta -short data/test_long.fa |
| 20 | ~/velvet_1.1.03$ ./velvetg output/ -exp_cov 3 -min_contig_lgth 100 |
| 21 | }}} |
| 22 | * <參考 1> [http://blog.dccmx.com/2011/01/gprof/ 讓程序飛 之 性能工具: gprof & gprof2dot] |
| 23 | * <參考 2> [http://blog.dccmx.com/2011/01/valgrind-memcheck/ 讓程序飛 之 內存工具: valgrind –tool=memcheck] |
| 24 | * <參考 3> [http://blog.dccmx.com/2011/01/valgrind-massif/ 讓程序飛 之 內存工具: valgrind –tool=massif & massif-visualizer] |
| 25 | * <參考 4> [http://blog.dccmx.com/2011/01/callgrind/ 讓程序飛 之 性能工具: valgrind –tool=callgrind & kcachegrind] |
| 26 | * 使用 [http://packages.debian.org/valgrind valgrind] 來進行記憶體分析 - (1) Memory Leak 分析 |
| 27 | {{{ |
| 28 | ~/velvet_1.1.03$ sudo apt-get install valgrind |
| 29 | ~/velvet_1.1.03$ valgrind -v --leak-check=full --show-reachable=yes --read-var-info=yes ./velveth output 17 -fasta -short data/test_long.fa 2> velveth.log |
| 30 | ~/velvet_1.1.03$ valgrind -v --leak-check=full --show-reachable=yes --read-var-info=yes ./velvetg output/ -exp_cov 3 -min_contig_lgth 100 2> velvetg.log |
| 31 | }}} |
| 32 | * 使用 [http://packages.debian.org/valgrind valgrind] 的 [http://valgrind.org/docs/manual/ms-manual.html Massif] 工具來進行記憶體分析 - (2) Memory Usage 分析 |
| 33 | * Valgrind's skin Massif ('valgrind --tool=massif application') traces memory usage of the application.[http://ktown.kde.org/~seli/memory/analysis.html 參考來源] |
| 34 | {{{ |
| 35 | ~/velvet_1.1.03$ valgrind --tool=massif ./velveth output 17 -fasta -short data/test_long.fa |
| 36 | ~/velvet_1.1.03$ ms_print massif.out.10571 |
| 37 | ~/velvet_1.1.03$ valgrind --tool=massif ./velvetg output/ -exp_cov 3 -min_contig_lgth 100 |
| 38 | ~/velvet_1.1.03$ ms_print massif.out.10561 |
| 39 | }}} |
| 40 | {{{ |
| 41 | -------------------------------------------------------------------------------- |
| 42 | Command: ./velveth output 17 -fasta -short data/test_long.fa |
| 43 | Massif arguments: (none) |
| 44 | ms_print arguments: massif.out.10571 |
| 45 | -------------------------------------------------------------------------------- |
| 46 | |
| 47 | |
| 48 | MB |
| 49 | 66.60^ @@@@@@@@@@# |
| 50 | | :@:::::::::@:::::::::::::::::::::::::::::::::::::::::@ # |
| 51 | | :@:::: ::::@ : : : @ # |
| 52 | | :@:::: ::::@ : : : @ # |
| 53 | | :@:::: ::::@ : : : @ # |
| 54 | | :@:::: ::::@ : : : @ # |
| 55 | | :@:::: ::::@ : : : @ # |
| 56 | | :@:::: ::::@ : : : @ # |
| 57 | | :@:::: ::::@ : : : @ # |
| 58 | | :@:::: ::::@ : : : @ # |
| 59 | | :@:::: ::::@ : : : @ # |
| 60 | | :@:::: ::::@ : : : @ # |
| 61 | | :@:::: ::::@ : : : @ # |
| 62 | | :@:::: ::::@ : : : @ # |
| 63 | | :@:::: ::::@ : : : @ # |
| 64 | | :@:::: ::::@ : : : @ # |
| 65 | | :@:::: ::::@ : : : @ # |
| 66 | | :@:::: ::::@ : : : @ # |
| 67 | | :@:::: ::::@ : : : @ # |
| 68 | | :@:::: ::::@ : : : @ # |
| 69 | 0 +----------------------------------------------------------------------->Mi |
| 70 | 0 120.8 |
| 71 | |
| 72 | Number of snapshots: 71 |
| 73 | Detailed snapshots: [2, 4, 57, 67, 68 (peak)] |
| 74 | |
| 75 | -------------------------------------------------------------------------------- |
| 76 | n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) |
| 77 | -------------------------------------------------------------------------------- |
| 78 | 0 0 0 0 0 0 |
| 79 | 1 201,656 34,224 34,099 125 0 |
| 80 | 2 14,964,257 33,864 33,747 117 0 |
| 81 | }}} |
| 82 | {{{ |
| 83 | -------------------------------------------------------------------------------- |
| 84 | Command: ./velvetg output/ -exp_cov 3 -min_contig_lgth 100 |
| 85 | Massif arguments: (none) |
| 86 | ms_print arguments: massif.out.10561 |
| 87 | -------------------------------------------------------------------------------- |
| 88 | |
| 89 | |
| 90 | MB |
| 91 | 2.277^ # |
| 92 | | # |
| 93 | | # |
| 94 | | # |
| 95 | | # |
| 96 | | # |
| 97 | | # |
| 98 | | # |
| 99 | | # |
| 100 | | # |
| 101 | | # |
| 102 | | # |
| 103 | | # |
| 104 | | # |
| 105 | | # |
| 106 | | # |
| 107 | | # |
| 108 | | @@@:: # |
| 109 | | ::@ ::: # |
| 110 | | :::@ :::::#:::::::@:::::::::@:::@:::::::::::::::::::::::::: |
| 111 | 0 +----------------------------------------------------------------------->Mi |
| 112 | 0 125.5 |
| 113 | |
| 114 | Number of snapshots: 73 |
| 115 | Detailed snapshots: [2, 5, 6, 14, 16, 22, 30 (peak), 42, 58, 68] |
| 116 | |
| 117 | -------------------------------------------------------------------------------- |
| 118 | n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B) |
| 119 | -------------------------------------------------------------------------------- |
| 120 | 0 0 0 0 0 0 |
| 121 | 1 896,153 8,888 8,478 410 0 |
| 122 | 2 1,973,156 11,872 11,099 773 0 |
| 123 | }}} |
| 124 | * <註> 目前有兩個工具可以把 ms_print 的 ASCII 圖變成更好看,一個是 KDE 的 [https://projects.kde.org/projects/extragear/sdk/massif-visualizer massif-visualizer],另一個是 GNOME 的 [http://live.gnome.org/MassifG MassifG](有 Ubuntu 套件在 PPA) |
| 125 | * <備註> [http://milianw.de/blog/massif-visualizer-now-with-user-interaction#comment-951 安裝 massif-visualizer 的步驟] |
| 126 | * 使用 [http://packages.debian.org/valgrind valgrind] 的 [http://valgrind.org/docs/manual/cl-manual.html callgrind] 工具來進行動態連結分析 |
| 127 | {{{ |
| 128 | ~/velvet_1.1.03$ valgrind --tool=callgrind ./velveth output 17 -fasta -short data/test_long.fa |
| 129 | ~/velvet_1.1.03$ valgrind --tool=callgrind ./velvetg output/ -exp_cov 3 -min_contig_lgth 100 |
| 130 | ~/velvet_1.1.03$ callgrind_annotate callgrind.out.12046 > velveth_callgrind.log |
| 131 | ~/velvet_1.1.03$ callgrind_annotate callgrind.out.12074 > velvetg_callgrind.log |
| 132 | }}} |
| 133 | * 使用 gprof 進行 profile 分析 |
| 134 | {{{ |
| 135 | ~/velvet_1.1.03$ cat Makefile | sed "s#^CFLAG.*#CFLAGS = -Wall -pg#" > Makefile.new |
| 136 | ~/velvet_1.1.03$ mv Makefile.new Makefile |
| 137 | ~/velvet_1.1.03$ make |
| 138 | ~/velvet_1.1.03$ ./velveth output 17 -fasta -short data/test_long.fa |
| 139 | ~/velvet_1.1.03$ du -sh gmon.out |
| 140 | 56K gmon.out |
| 141 | ~/velvet_1.1.03$ ./velvetg output/ -exp_cov 3 -min_contig_lgth 100 |
| 142 | ~/velvet_1.1.03$ du -sh gmon.out |
| 143 | 152K gmon.out |
| 144 | ~/velvet_1.1.03$ gprof velveth > velveth.log |
| 145 | ~/velvet_1.1.03$ gprof velvetg > velvetg.log |
| 146 | }}} |
| 147 | * 使用 [http://code.google.com/p/jrfonseca/wiki/Gprof2Dot gprof2dot] 把 gprof log 轉成 graphviz 的 dot 格式,就可以畫出圖形了。 |
| 148 | {{{ |
| 149 | ~/velvet_1.1.03$ sudo apt-get install graphviz python |
| 150 | ~/velvet_1.1.03$ wget http://gprof2dot.jrfonseca.googlecode.com/hg/gprof2dot.py |
| 151 | ~/velvet_1.1.03$ chmod a+x gprof2dot.py |
| 152 | ~/velvet_1.1.03$ gprof velveth | ./gprof2dot.py | dot -Tpng -o velveth.png |
| 153 | ~/velvet_1.1.03$ gprof velvetg | ./gprof2dot.py | dot -Tpng -o velvetg.png |
| 154 | }}} |
| 155 | * [[Image(jazz/11-05-04:velveth.png)]] |
| 156 | * [[Image(jazz/11-05-04:velvetg.png)]] |