高効率なアプリケーション実行 • 各計算機特性は異なり、それぞれに最適化された環境が必要 • e.g., ハードウェア性能や構成、電力制約など 3. 可搬性 • オフロードやハンドオフには、アプリケーションと実行状態を 共に移動するライブマイグレーションが必要不可欠 [1] J. Shuja, S. Mustafa, R. W. Ahmad, S. A. Madani, A. Gani and M. Khurram Khan, "Analysis of Vector Code Offloading Framework in Heterogeneous Cloud and Edge Architectures," IEEE Access, vol. 5, pp. 24542-24554, 2017. 内部実行状態
$p1 local.get $p2 i32.add call $hoge … … call $analysis local.get $p1 call $analysis local.get $p2 call $analysis i32.add call $analysis … ランタイムごとに独自の実装が必要 状態変換が複雑化 ネイティブコンパイル時の命令挿入[4] 特定のコンパイラ基盤と 実行方式に依存 バイトコードの事前改変[3] 外部の分析関数を呼び出すことで オーバヘッドが増大 ランタイムA Wasmバイトコード 内部実行状態保存・復元 for A ランタイムB Wasmバイトコード 内部実行状態保存・復元 for B [2] D. Fujii, K. Matsubara, and Y. Nakata, “Stateful VM Migration Among Heterogeneous WebAssembly Runtimes for Efficient Edge-cloud Collaborations”, Proceedings of the 7th International Workshop on Edge Systems, Analytics and Networking, pp. 19–24, Apr. 2024, doi: https://doi.org/10.1145/3642968.3654816. [3] D. Lehmann and M. Pradel, “Wasabi: A framework for dynamically analyzing webassembly”, Architectural Support for Programming Languages and Operating Systems, Apr. 2019, doi: https://doi.org/10.1145/3297858.3304068 [4] Y. Yang, A. Hu, Y. Zheng, B. Zhao, X. Zhang, and A. Quinn, “Transparent and Efficient Live Migration across Heterogeneous Hosts with Wharf”, arXiv (Cornell University), Oct. 2024, doi: https://doi.org/10.48550/arXiv.2410.15894 マイグレーション可能 ネイティブバイナリ コンパイル時 に挿入 ライブマイグレーション用 命令(中間表現)
実行時間(秒) Wasm3 83.53 セルフホストWasm3 on Wasm3 3125.61 Wasmtime 14.02 セルフホストWasm3 on Wasmtime 1579.32 37倍 112倍 ベンチマーク実行結果[5] [5] Y. Nakata and K. Matsubara, “Poster: Feasibility of Runtime-Neutral Wasm Instrumentation for Edge-Cloud Workload Handover”, pp. 528–530, Dec. 2024, doi: https://doi.org/10.1109/sec62691.2024.00068.
[6] Matthew Kolosick, Shravan Narayan, Evan Johnson, Conrad Watt, Michael LeMay, Deepak Garg, Ranjit Jhala, and Deian Stefan. Isolation without taxation: near-zero-cost transitions for webassembly and sfi. Proc. ACM Program. Lang., Vol. 6, No. POPL, jan 2022. [7] Raven Szewczyk, Kimberley Stonehouse, Antonio Barbalace, and Tom Spink. Leaps and bounds: Analyzing webassembly ’s performance with a fo- cus on bounds checking. In 2022 IEEE Interna- tional Symposium on Workload Characterization (IISWC), pp. 256–268, 2022. サンドボックス 型の一致や 命令の有効性を検証 0x00 0xff 実行中の 境界値チェックなど アプリケーションの バイトコード
サンドボックス 0x00 0xff セルフホストランタイムの バイトコード アプリケーションの バイトコード セルフホストランタイム のサンドボックス 二重の検証 0x00 0xff 二重のチェック [6] Matthew Kolosick, Shravan Narayan, Evan Johnson, Conrad Watt, Michael LeMay, Deepak Garg, Ranjit Jhala, and Deian Stefan. Isolation without taxation: near-zero-cost transitions for webassembly and sfi. Proc. ACM Program. Lang., Vol. 6, No. POPL, jan 2022. [7] Raven Szewczyk, Kimberley Stonehouse, Antonio Barbalace, and Tom Spink. Leaps and bounds: Analyzing webassembly ’s performance with a fo- cus on bounds checking. In 2022 IEEE Interna- tional Symposium on Workload Characterization (IISWC), pp. 256–268, 2022.
fn f64_nearest(…) -> …{ let x = value_stack.pop(); let y = x.fract(); let result = if y == 0.5 { x.floor() } else if y == -0.5 { x.ceil() } else { x.round() }; … } fn f64_nearest(…) -> …{ let x = value_stack.pop(); asm!( "local.get {0}", "f64.nearest", "local.set {1}", in(local) x, out(local) result, ); … }