2018-05-22---- # Approximateネットワークに対する速性と計算精度の最適化基盤 - 2000年くらいから計算機は高速化を考えてきたが,クロックや消費電力などの問題があった - そろそろこのトレードオフだけでは辛くなってきた - ムーア時代 - 性能/電力効率を探求 - 厳密さ - 数の丸め誤差 - 複数の出力が解となるアプリ ==> Perfect Executionは不要 - ニューラルネットワークをアナログ演算回路で実現している - 昨今 - 不真面目な計算機*真面目なネットワーク - データ通信帯域が増加するにつれてエラー訂正がレイテンシを低下させてしまう - Approximate Network - 帯域10倍 - 遅延増えない - エラー放置 - アプリによってビット誤りの許容が異なる - ビットの保護する場所が変動する - 保護するビットをマスクしてあげることで,エラーを考慮しない部分と見ていく - 正しくない実行結果が出力されるパターンの近くを探索しない - OpenTunerによる探索空間を定義している # 大規模ソフトウェアにおけるコンパイル時間の定量的分析と高速化手法の提案 - 90%以上がコンパイラで締められている - edit-compile-testのサイクルで開発を行っているので厳しい - Incrementaal BuilDing - GNU Make - Ninja - CMake - ccache - key-value-storeで管理している - WebKit - ほぼ毎日大規模ファイルをコンパイルする必要が出てきている - コンパイラ単体のスループットを上げる必要がある - 同一ヘッダーファイルのコンパイルが2千件行われている - 再利用時には一貫性が保たれている必要がある - Hello Worldのコンパイルが最大8.7倍 => もともと並列性の高いものをターゲットにした場合 --> オーバーヘッドを考える事はあまり無いのではないのか # Christie - ファイルシステムの問題点 - 型がない - トランザクションが提供されてない - SQLですら厳しい - 分散環境でアクセス方式が定まってない - Christie - Linda - Christieの - ファイルシステムの型 - 不整合時にどうするかの処理を付けないといけない - annotationを使ったput/takeのもの - unixファイルシステムは木構造の名前管理構造を持っている - ファイル自体もi-nodeを使った木構造が導入されている - トランザクションの失敗の扱いを上手い具合にする - メモリ自信のハードエラーは提案論文が少ない # カーネル内部データのプロセス間分離による堅牢性の向上 ## Kernel Failure - エラー伝搬が発生するとKernel Failureを引き起こす可能性がある - プロセスコンテキストに閉じて発生する - プロセスローカルデータ(単一のプロセスコンテキストで使用されるデータ) - カーネル内で共有するデータにエラーが伝搬した場合修復が難しい - プロセスを強制終了させることでプログセスコンテキストを切り離す事ができる - Software failer - 'プロセスローカルエラー' # 耐ビザンチン障害性を持つ分散合意手法の調査 - 決済システムなどでブロックチェーン技術が利用されている - PoW - PBFT ( Practical Byzantine Fault Tol) - http://pmg.csail.mit.edu/papers/osdi99.pdf - "スループット" - rsocketをもちいた場合 [[Perl6]] * 具体的に遅い箇所を計測した方がいい * どうやって計測を図るか * コンパイラ構成論の資料を読んでオブジェクトパターンを理解しておく - Key Value Store ---------- 2018-05-25---- Perl6 - [助成金貰って高速化](http://news.perlfoundation.org/2017/11/perl-6-performance-and-reliabi-4.html) - インライン展開周り - インラインclosureが実装された - dead codeを削除 ---------- 2018-05-26---- marking - distributed snapshot ---------- 2018-05-27---- - trap_swi - システムコール ---------- 2018-05-28---- マシンを変えたからgccでコンパイルしようとすると厳しい compiling 3rdparty/libuv/src/unix/fsevents.o compiling 3rdparty/libuv/src/unix/timer.o compiling 3rdparty/libuv/src/unix/tty.o compiling 3rdparty/libuv/src/unix/udp.o /Users/anatofuz/.plenv/versions/5.24.4/bin/perl5.24.4 build/mk-moar-pc.pl pkgconfig/moar.pc In file included from /System/Library/Frameworks/Security.framework/Headers/AuthSession.h:32, from /System/Library/Frameworks/Security.framework/Headers/Security.h:43, from /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/CSIdentity.h:43, from /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/OSServices.h:27, from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/IconsCore.h:23, from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LaunchServices.h:22, from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:39, from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23, from 3rdparty/libuv/src/unix/darwin-proctitle.c:33: /System/Library/Frameworks/Security.framework/Headers/Authorization.h:193:7: error: variably modified 'bytes' at file scope char bytes[kAuthorizationExternalFormLength]; ^~~~~ In file included from /System/Library/Frameworks/Security.framework/Headers/AuthSession.h:32, from /System/Library/Frameworks/Security.framework/Headers/Security.h:43, from /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/CSIdentity.h:43, from /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/OSServices.h:27, from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/IconsCore.h:23, from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LaunchServices.h:22, from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:39, from 3rdparty/libuv/src/unix/fsevents.c:49: /System/Library/Frameworks/Security.framework/Headers/Authorization.h:193:7: error: variably modified 'bytes' at file scope char bytes[kAuthorizationExternalFormLength]; ^~~~~ In file included from /System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h:21, from /System/Library/Frameworks/CoreGraphics.framework/Headers/CGBitmapContext.h:9, from /System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:11, from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:35, from 3rdparty/libuv/src/unix/darwin-proctitle.c:33: /System/Library/Frameworks/CoreGraphics.framework/Headers/CGPath.h:391:15: error: expected identifier or '(' before '^' token typedef void (^CGPathApplyBlock)(const CGPathElement * element); ^ /System/Library/Frameworks/CoreGraphics.framework/Headers/CGPath.h:393:53: error: unknown type name 'CGPathApplyBlock' CG_EXTERN void CGPathApplyWithBlock(CGPathRef path, CGPathApplyBlock CF_NOESCAPE block) ^~~~~~~~~~~~~~~~ make: *** [3rdparty/libuv/src/unix/fsevents.o] Error 1 make: *** Waiting for unfinished jobs.... make: *** [3rdparty/libuv/src/unix/darwin-proctitle.o] Error 1 ---------- 2018-05-29---- ❯ lldb -- /Users/anatofuz/workspace/cr/Basic/build_perl6/bin/moar nqp.moarvm examples/hello_world.nqp [13:52:54] (lldb) target create "/Users/anatofuz/workspace/cr/Basic/build_perl6/bin/moar" Current executable set to '/Users/anatofuz/workspace/cr/Basic/build_perl6/bin/moar' (x86_64). (lldb) settings set -- target.run-args "nqp.moarvm" "examples/hello_world.nqp" (lldb) b add_bb_facts Breakpoint 1: where = libmoar.dylib`add_bb_facts + 32 at facts.c:362, address = 0x0000000000118540 (lldb) c error: invalid process (lldb) run Process 8479 launched: '/Users/anatofuz/workspace/cr/Basic/build_perl6/bin/moar' (x86_64) Process 8479 stopped * thread #2, stop reason = breakpoint 1.1 frame #0: 0x00000001001bb540 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:362 359 MVMint32 i, is_phi; 360 361 /* Look for instructions that provide or propagate facts. */ -> 362 MVMSpeshIns *ins = bb->first_ins; 363 while (ins) { 364 /* See if there's deopt and logged annotations. Sync cur_deopt_idx 365 * and, for logged+deopt-one, add logged facts and guards. */ Target 0: (moar) stopped. (lldb) bt * thread #2, stop reason = breakpoint 1.1 * frame #0: 0x00000001001bb540 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:362 frame #1: 0x00000001001bb503 libmoar.dylib`MVM_spesh_facts_discover(tc=0x0000000100802e30, g=0x0000000100f4efe0, p=0x0000000100f514d0) at facts.c:659 frame #2: 0x00000001001b4eb7 libmoar.dylib`MVM_spesh_candidate_add(tc=0x0000000100802e30, p=0x0000000100f514d0) at candidate.c:61 frame #3: 0x00000001001cf991 libmoar.dylib`worker(tc=0x0000000100802e30, callsite=0x00000001006c9150, args=0x0000000000000000) at worker.c:16 frame #4: 0x000000010014e8e2 libmoar.dylib`invoke_handler(tc=0x0000000100802e30, invokee=0x0000000102014840, callsite=0x00000001006c9150, args=0x0000000000000000) at MVMCFunction.c:9 frame #5: 0x00000001000e8494 libmoar.dylib`thread_initial_invoke(tc=0x0000000100802e30, data=0x0000000100802050) at threads.c:59 frame #6: 0x00000001000aefee libmoar.dylib`MVM_interp_run(tc=0x0000000100802e30, initial_invoke=(libmoar.dylib`thread_initial_invoke at threads.c:50), invoke_data=0x0000000100802050) at interp.c:93 frame #7: 0x00000001000e7a35 libmoar.dylib`start_thread(data=0x0000000100802050) at threads.c:87 frame #8: 0x00007fff7b9fe661 libsystem_pthread.dylib`_pthread_body + 340 frame #9: 0x00007fff7b9fe50d libsystem_pthread.dylib`_pthread_start + 377 frame #10: 0x00007fff7b9fdbf9 libsystem_pthread.dylib`thread_start + 13 (lldb) n Process 8479 stopped * thread #2, stop reason = step over frame #0: 0x00000001001bb579 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:370 367 MVMSpeshAnn *ann_deopt_one = NULL; 368 MVMSpeshAnn *ann_logged = NULL; 369 MVMint32 is_deopt_ins = 0; -> 370 while (ann) { 371 switch (ann->type) { 372 case MVM_SPESH_ANN_DEOPT_ONE_INS: 373 ann_deopt_one = ann; Target 0: (moar) stopped. (lldb) Process 8479 stopped * thread #2, stop reason = step over frame #0: 0x00000001001bb620 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:385 382 } 383 ann = ann->next; 384 } -> 385 if (ann_deopt_one && ann_logged) 386 log_facts(tc, g, bb, ins, p, ann_deopt_one, ann_logged); 387 388 /* Look through operands for reads and writes. */ Target 0: (moar) stopped. (lldb) l 389 is_phi = ins->info->opcode == MVM_SSA_PHI; 390 for (i = 0; i < ins->info->num_operands; i++) { 391 /* Reads need usage tracking; if the read is after a deopt point 392 * relative to the write then give it an extra usage bump. */ 393 if ((is_phi && i > 0) 394 || (!is_phi && (ins->info->operands[i] & MVM_operand_rw_mask) == MVM_operand_read_reg)) { 395 MVMSpeshFacts *facts = &(g->facts[ins->operands[i].reg.orig][ins->operands[i].reg.i]); (lldb) l 396 facts->usages += facts->deopt_idx == cur_deopt_idx ? 1 : 2; 397 } 398 399 /* Writes need the current deopt index and the writing instruction 400 * to be specified. A write that's on a deopt instruction bumps 401 * the usage too. */ 402 if ((is_phi && i == 0) (lldb) n Process 8479 stopped * thread #2, stop reason = step over frame #0: 0x00000001001bb65b libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:389 386 log_facts(tc, g, bb, ins, p, ann_deopt_one, ann_logged); 387 388 /* Look through operands for reads and writes. */ -> 389 is_phi = ins->info->opcode == MVM_SSA_PHI; 390 for (i = 0; i < ins->info->num_operands; i++) { 391 /* Reads need usage tracking; if the read is after a deopt point 392 * relative to the write then give it an extra usage bump. */ Target 0: (moar) stopped. (lldb) p MVM_SSA_PHI error: use of undeclared identifier 'MVM_SSA_PHI' (lldb) nexr error: 'nexr' is not a valid command. error: Unrecognized command 'nexr'. (lldb) n Process 8479 stopped * thread #2, stop reason = step over frame #0: 0x00000001001bb677 libmoar.dylib`add_bb_facts(tc=0x0000000100802e30, g=0x0000000100f4efe0, bb=0x0000000102115e00, p=0x0000000100f514d0, cur_deopt_idx=-1) at facts.c:390 387 388 /* Look through operands for reads and writes. */ 389 is_phi = ins->info->opcode == MVM_SSA_PHI; -> 390 for (i = 0; i < ins->info->num_operands; i++) { 391 /* Reads need usage tracking; if the read is after a deopt point 392 * relative to the write then give it an extra usage bump. */ 393 if ((is_phi && i > 0) Target 0: (moar) stopped. (lldb) p is_phi (MVMint32) $14 = 0 (lldb) p ins (MVMSpeshIns *) $15 = 0x0000000102115e60 (lldb) p *ins (MVMSpeshIns) $16 = { info = 0x00000001005757c0 operands = 0x0000000000000000 prev = 0x0000000000000000 next = 0x0000000000000000 annotations = 0x0000000000000000 } (lldb) p *ins->info (MVMOpInfo) $17 = { opcode = 0 name = 0x00000001002def92 "no_op" mark = { [0] = ' ' [1] = ' ' } num_operands = 0 pure = '\0' deopt_point = '\0' logged = '\0' no_inline = '\0' jittivity = '\0' uses_hll = '\0' operands = ([0] = '\0', [1] = '\0', [2] = '\0', [3] = '\0', [4] = '\0', [5] = '\0', [6] = '\0', [7] = '\0') } ----------