Skip to content

Commit 1f10a67

Browse files
committed
文章を追加
1 parent b70cc4c commit 1f10a67

15 files changed

+487
-149
lines changed

bib/main.bib

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
@misc{esp32,
2-
author = "Espressif Systems (Shanghai) PTE LTD",
2+
author = "Espressif Systems (Shanghai) Pte. Ltd.",
33
title = "{ESP32 Series Datasheet}",
44
year = 2018,
55
howpublished = "\url{https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf}",
66
}
77

88
@misc{esp_idf,
9-
author = "{Espressif Systems (Shanghai) PTE LTD}",
9+
author = "{Espressif Systems (Shanghai) Pte. Ltd.}",
1010
title = "{ESP-IDF Programming Guide}",
1111
howpublished = "\url{https://docs.espressif.com/projects/esp-idf}"
1212
}
1313

1414
@misc{esp_toolchain,
15-
author = "{Espressif Systems (Shanghai) PTE LTD}",
15+
author = "{Espressif Systems (Shanghai) Pte. Ltd.}",
1616
title = "{Get Started - ESP-IDF Programming Guide}",
1717
howpublished = "\url{https://docs.espressif.com/projects/esp-idf/en/latest/get-started/#setup-toolchain}"
1818
}
@@ -23,7 +23,7 @@ @misc{arduino_ide
2323
}
2424

2525
@misc{esp_arduino,
26-
author = "{Espressif Systems (Shanghai) PTE LTD}",
26+
author = "{Espressif Systems (Shanghai) Pte. Ltd.}",
2727
title = "{Arduino core for ESP32 WiFi chip}",
2828
howpublished = "\url{https://github.com/espressif/arduino-esp32}"
2929
}
@@ -59,17 +59,44 @@ @misc{go_wasm
5959
}
6060

6161
@misc{micropython,
62-
author = "{George Robotics Limited}",
62+
\urlauthor = "{George Robotics Limited}",
6363
title = "{MicroPython - Python for microcontrollers}",
6464
howpublished = "\url{http://micropython.org}"
6565
}
6666

67+
@misc{mpy-cross,
68+
title = "{MicroPython cross compiler}",
69+
howpublished = "\url{https://github.com/micropython/micropython/blob/master/mpy-cross/README.md}"
70+
}
71+
72+
@misc{ethereum,
73+
title = "{Ethereum Project}",
74+
howpublished = "\url{https://www.ethereum.org}"
75+
}
76+
77+
@misc{ewasm,
78+
title = "{ewasm Design Overview and Specification}",
79+
howpublished = "\url{https://github.com/ewasm/design}"
80+
}
81+
6782
@misc{esp_ota,
68-
author = "{Espressif Systems (Shanghai) PTE LTD}",
83+
author = "{Espressif Systems (Shanghai) Pte. Ltd.}",
6984
title = "{Over The Air Updates (OTA) — ESP-IDF Programming Guide}",
7085
howpublished = "\url{https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/system/ota.html}"
7186
}
7287

88+
@misc{webkit_spectre,
89+
author = "{WebKit}",
90+
title = "{What Spectre and Meltdown Mean For WebKit}",
91+
howpublished = "\url{https://webkit.org/blog/8048/what-spectre-and-meltdown-mean-for-webkit}"
92+
}
93+
94+
@misc{webkit_trac,
95+
author = "{WebKit}",
96+
title = "{Changeset 226495 in webkit ("Reduce the precision of "high" resolution time to 1ms")}",
97+
howpublished = "\url{https://trac.webkit.org/changeset/226495/webkit}"
98+
}
99+
73100
@techreport{rfc7228,
74101
author = "C. Bormann and M. Ersue and A. Keranen",
75102
title = "{Terminology for Constrained-Node Networks}",
@@ -94,11 +121,18 @@ @book{jvms
94121
year = 2001,
95122
}
96123

97-
@book{ieee754,
98-
title={{IEEE standard for binary floating-point arithmetic}},
99-
booktitle={{IEEE standard for binary floating-point arithmetic}},
100-
publisher={Institute of Electrical and Electronics Engineers},
101-
year={1985}
124+
@ARTICLE{ieee754,
125+
author={},
126+
journal={{IEEE Std 754-2008}},
127+
title={{IEEE Standard for Floating-Point Arithmetic}},
128+
year={2008},
129+
volume={},
130+
number={},
131+
pages={1-70},
132+
keywords={floating point arithmetic;IEEE standards;programming;IEEE standard;decimal floating-point arithmetic;computer programming;arithmetic formats;754-2008;arithmetic;binary;computer;decimal;exponent;floating-point;format;interchange;NaN;number;rounding;significand;subnormal},
133+
doi={10.1109/IEEESTD.2008.4610935},
134+
ISSN={},
135+
month={Aug},
102136
}
103137

104138
@book{dwarf,

img/eval_envs.pdf

47 KB
Binary file not shown.

img/static_dynamic.pdf

40.4 KB
Binary file not shown.

img/wasm_design.pdf

-658 Bytes
Binary file not shown.

img/wasm_module.pdf

464 Bytes
Binary file not shown.

img/wasm_section.pdf

42 KB
Binary file not shown.

src/000_meta.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
\bibliographystyle{jplain}
2626

2727
\jclass {卒業論文}
28-
\jtitle {マイコン向けWebAssembly実行環境の実装と評価}
28+
\jtitle {マイコン向けWebAssembly実行環境の\\設計と実装}
2929
\juniv {慶應義塾大学}
3030
\jfaculty {環境情報学部}
3131
\jauthor {安井 瑛男}

src/001_abstract.ja.tex

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
\begin{jabstract}
22

3-
あとで書く
3+
マイコンにおけるプログラムは通常、フラッシュメモリ等のRAMに書き込まれ、起動時にブートローダがプログラムを参照して静的に実行される。
4+
そのため、処理内容を変更するためには、有線接続によって、もしくは無線接続によるOTA(Over-the-air)アップデートによって、フラッシュメモリ上のプログラムを書き換えた上で再起動する必要がある。
5+
6+
一方、Webページとして提供されるWebアプリケーションでは、プログラムは動的に実行される。
7+
Webブラウザはアプリケーション・プラットフォームとして、Webページに記述されたスクリプトや外部へのリンクを辿り、必要なプログラムを取得した上で実行する。
8+
これにより、アクセスするWebページごとに異なるアプリケーションを提供することができる上に、利用者の環境や状態によって処理内容を変更することもできる。
9+
10+
そこで、動的なアプリケーションの実行モデルをマイコン上でも実現するため、WebAssemblyを実行形式として用いたアプリケーション・プラットフォームの設計を提案する。
11+
WebAssemblyは、Webブラウザ上で実行するためのプログラムを記述できる仮想的な命令セットアーキテクチャであり、Webブラウザにおける動的なアプリケーション実行モデルを高速化するために設計された。
12+
Webブラウザでの実行を第一義的な用途として設計されたWebAssemblyだが、仕様としてWebブラウザ内での使用に限定する制約はない。
13+
14+
本研究では、マイコンにおいてWebAssemblyプログラムの動的な取得と実行を行う、マイコン向けWebAssembly実行環境を設計した。
15+
その上で、本実行環境の実現可能性を検討するため、C言語でWebAssemblyインタプリタを実装した。
16+
17+
実装した実行環境を用いて、ESP32およびIntel Core i5 3GHzのCPUを搭載したPCで同一のWebAssemblyプログラムをそれぞれ実行した結果、ESP32ではPCの7倍から15倍程度のクロック数を必要とすることが分かった。
18+
この結果を、同じWebAssemblyプログラムをPCのWebブラウザ上で実行した際の性能と比較した結果、Webブラウザと同等の実行性能を持ったWebAssembly実行環境をESP32上に実装した場合、30番目のフィボナッチ数を約560ミリ秒で計算できる性能となることが推測された。
419

520
\end{jabstract}

src/002_abstract.en.tex

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
\begin{eabstract}
22

3-
あとで書く
3+
Microcontrollers statically execute their program written on its RAM such as a flash memory, loading it by the boot loader at startup.
4+
Consequently, in order to change what to run, restarting after getting the program on the RAM rewritten by connecting it directly, or doing OTA (Over-the-air) update over a wireless connection.
5+
6+
On the other hand, Web applications load and execute programs dynamically.
7+
As an application platform, the Web browser follows links on a Web page and executes downloaded programs.
8+
That is why different applications can be provided for each Web page and programs can be changed depending on the user environment.
9+
10+
We propose the design of an application platform which uses WebAssembly as the executable format to make dynamic execution possible on microcontrollers.
11+
WebAssembly is a virtual instruction set architecture designed to be run on Web browsers and to speed up the dynamic execution on Web browsers.
12+
Although it is mainly aimed at being executed on Web browsers, its specification has no restriction nor limit against being used outside Web browsers.
13+
14+
In this research, we designed a WebAssembly runtime for microcontrollers which dynamically downloads and runs WebAssembly programs.
15+
And we implemented a WebAssembly interpreter in C language, in order to evaluate the feasibility of this runtime.
16+
17+
We executed a single WebAssembly binary on an ESP32 microcontroller and on a PC with Intel Core i5 3GHz CPU.
18+
As a result, we found that the ESP32 requires 7 to 15 times as many clocks as the PC.
19+
Applying this result to the execution time on Safari Web browser to run the same WebAssembly program on the PC, it was estimated that a WebAssembly runtime which has execution efficiency as Web browsers will be able to calculate 30th Fibonacci number in 560 msec approximately.
420

521
\end{eabstract}

src/010_introduction.ja.tex

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,63 @@ \chapter{序論}
44
\section{背景}
55
\label{section:background}
66

7-
今日、World Wide Webは静的な文書の配信のみならず、動的なアプリケーション・プラットフォームとしても広く用いられている。
87

9-
Webにおけるアプリケーションの配信・実行を支援する技術の一つに、WebAssemblyがある。
10-
WebAssemblyは、Google、Microsoft、MozillaおよびAppleの主導によって開発された仮想命令セットである\cite{webassembly}。
11-
従来、WebブラウザにおいてはECMAScript(JavaScript)が事実上唯一の標準化された実行形式であった。
12-
しかし、ECMAScriptはスクリプト言語として設計された言語であり\cite{ecma2018}、プログラムサイズやソースコードのパースを含めた実行速度においてオーバーヘッドがある。
13-
WebAssemblyは、プログラムの実行前に別のホストからダウンロードされることを想定して、実行ファイルのサイズが可能な限り小さくなるように設計されている。
8+
現在、マイコンにおけるプログラムは静的に実行されるのが主流である。
9+
すなわち、プログラムはフラッシュメモリ等に書き込まれ、起動時にブートローダがプログラムを参照して実行する。
10+
そのため、処理内容を変更するためには、有線接続によってか、もしくは無線接続によるOTA(Over-the-Air)アップデートによって、フラッシュメモリ上のプログラムを書き換えた上で再起動する必要がある。
11+
12+
他方、Webページとして提供されるWebアプリケーションでは、プログラムは動的に実行される。
13+
Webブラウザはアプリケーション・プラットフォームとして、Webページに記述されたスクリプトや外部へのリンクを辿り、必要なプログラムを取得した上で実行する。
14+
これにより、アクセスするWebページごとに異なるアプリケーションを提供することができる上に、利用者の環境や状態によって処理内容を変更することもできる。
15+
16+
WebAssemblyは、こうしたWebアプリケーションにおける動的なプログラム実行を高速化するために設計された、Webブラウザ上で動作する仮想命令セットアーキテクチャである。
17+
従来、Webブラウザにおいては、ECMAScript(JavaScript)が事実上唯一の標準化された実行形式であった。
18+
しかし、ECMAScriptはスクリプト言語として設計された言語であり\cite{ecma2018}、プログラムサイズの効率化や、ソースコードのパースを含めた実行速度の最適化には限界があった。
19+
WebAssemblyは、Webブラウザ上で動作するプログラムとしてネイティブ実行に近いパフォーマンスを得ることを目標として設計されている。
20+
また、プログラムがインターネット上からダウンロードして実行されることを想定して、プログラムサイズが小さく効率的にパースできるようにバイナリフォーマットが定義されている。
1421
また、実行ファイル全体がダウンロードされるのを待つことなく逐次的に実行することも可能であり、直ちに必要としない部分の読み込みは遅延させたり並列化させたりすることができる。
1522

16-
このWebAssemblyを実行形式として選択できるソフトウェア開発環境は増えつつある。
17-
コンパイラ基盤であるLLVMが試験的にWebAssemblyをコンパイルターゲットとして対応した\cite{}ことにより、C言語/C++言語や、Rust言語\cite{rust_wasm}からWebAssemblyへコンパイルすることが可能になった。
18-
また、Go言語はLLVMとは独立にWebAssemblyをコンパイルターゲットとして対応した\cite{go_wasm}。
19-
プログラミング言語やライブラリにおけるWebAssembly対応が広がることで、多様な開発環境を用いて開発したプログラムをWebブラウザ上で高速かつ安全に実行できるようになる。
23+
実行形式としてのWebAssemblyプログラムの出力に対応したソフトウェア開発環境は増えつつある。
24+
コンパイラ基盤であるLLVMが試験的にWebAssemblyをコンパイルターゲットとして対応したことにより、C/C++やRust\cite{rust_wasm}、C\#\cite{mono_wasm}といった言語からWebAssemblyへコンパイルすることが可能になった。
25+
また、GoはLLVMとは独立にWebAssemblyをコンパイルターゲットとして対応した\cite{go_wasm}。
2026

2127
また、WebAssemblyプログラムを実行するための環境として主に想定されているのはWebブラウザだが、WebAssemblyの設計自体にはWebブラウザに限定された仕様は含まれておらず、Webブラウザ外への応用も想定されている。
22-
非Webブラウザ環境でも実行環境としてWebAssemblyを用いることで、実行に必要なプログラムを適宜ダウンロードしてサンドボックス内で実行するというWebにおける実行モデルを、幅広い環境に応用することができる
28+
例えば、分散型アプリケーションプラットフォームであるEthereumでは、各クライアントで動作する仮想マシンの命令セットとしてWebAssemblyのサブセットを用いるべく開発が進められている\cite{ewasm}
2329

2430
\section{本研究が着目する課題}
2531

26-
WebAssemblyは非Webブラウザ環境での実行も想定して設計されているため、Webブラウザのような多機能なソフトウェアを動作させることが難しい、計算資源が限られた環境に応用することも可能である。
27-
しかし、マイコンなどにおけるWebAssemblyの応用可能性は十分に検証されていない。
32+
本研究では、マイコンでプログラムの実行が静的にしか行えない点に着目する。
33+
利用者の操作や遠隔からのコマンド送信をきっかけとして処理内容を変更する場合、記憶容量が限られたマイコンにおいて全てのプログラムを網羅的に保持するのは難しい。
34+
また、一般にフラッシュメモリにプログラムを書き込み直した後で実行内容を更新するには再起動が必要であり、実行内容の切り替えをスムーズに行えない。
35+
36+
マイコンの性能向上により小規模な端末においてもインターネットへの接続性が普及しつつある中、マイコンで動的なプログラムの取得・実行を行う事ができれば、実現できる機能の幅を大きく広げる事ができる。
2837

29-
接続した端末に直接プログラムを書き込むことが一般的であるマイコンにおいて、WebAssembly実行環境があれば、マイコン上で動作するプログラムをWebからダウンロードして実行することが可能になり、利便性が向上する。
38+
\begin{figure}[htbp]
39+
\caption{マイコンにおける静的な実行モデルと動的な実行モデル}
40+
\label{fig:static_dynamic}
41+
\begin{center}
42+
\includegraphics[bb=0 0 660 633,width=14cm]{img/static_dynamic.pdf}
43+
\end{center}
44+
\end{figure}
3045

3146
\section{本研究の目的とアプローチ}
3247

33-
本研究では前述の課題を解決するため、マイコンのような計算資源が限られた環境下でもWebAssemblyバイナリが実行できることを示し、Webを用いたソフトウェアの配布およびアップデートが可能であることを示す
48+
本研究では、WebAssemblyを実行形式として用いる事で、マイコンのような計算資源が限られた環境下でもプログラムの動的な実行ができることを示し、前述の課題を解決する
3449

35-
そのために、本研究ではマイコン上でWebAssemblyバイナリの取得、実行および更新を行うための実行環境を設計した
36-
また、その実現可能性を示すため、ESP32マイコン上にWebAssemblyバイナリのインタプリタを実装し、性能を評価した
50+
そのために、本研究ではマイコン上でWebAssemblyバイナリの取得、実行および更新を行うための実行環境を設計した上で、その実現可能性を示すため、C言語によりWebAssemblyバイナリのインタプリタを実装し、ESP32マイコンとPC上でそれぞれ同一のWebAssemblyを実行できることを示した
51+
また、それぞれの環境での実行性能を、PC上のWebブラウザにおけるWebAssemblyバイナリの実行性能と比較する事で、マイコンにおけるWebAssembly実行環境の性能を検討した
3752

3853
\section{本論文の構成}
3954

4055
本論文における以降の構成は次の通りである。
4156

42-
\ref{chap:related_works}章では、マイコンにおけるプログラムの更新を行うための関連技術として、MicroPython、ESP-IDFが提供するOTA機能およびAmazon FreeRTOSが提供するOTA機能について述べる
57+
\ref{chap:related_works}章では、マイコンにおけるプログラムの更新を行うための関連技術として、MicroPythonおよびESP-IDFが提供するOTA機能について述べる
4358

4459
\ref{chap:design}章では、マイコン上でWebAssemblyプログラムを取得、実行、更新するための実行環境の設計を提案する。提案する実行環境では、プログラムをHTTP通信を用いてインターネット上から取得する。プログラムは実行毎に再取得することで更新しつつ、キャッシュの活用により通信による計算負荷と帯域を削減する。
4560

4661
\ref{chap:implementation}章では、本研究で実装したWebAssembly実行環境について述べる。
4762
本研究では、WebAssemblyバイナリの実行部分を実装した。ホストプログラムから静的なバイナリをパースおよびインスタンス化し、対応する関数を呼び出すことで実行する。
4863

49-
\ref{chap:evaluation}章では、本研究で実装したWebAssembly実行環境について、同一の内容の関数をネイティブに実行した場合と比較し、実行速度およびメモリフットプリントにおけるオーバーヘッドについて考察する
64+
\ref{chap:evaluation}章では、本研究で実装したWebAssembly実行環境を用いて、ESP32マイコン上およびmacOSを搭載したPC上で同一のWebAssemblyバイナリを実行した結果と、PC上のWebブラウザで同じWebAssemblyバイナリを実行した結果を比較し、マイコンにおけるWebAssembly実行環境の性能を検討する
5065

5166
\ref{chap:conclusion}章では、本研究における結論を示す。

0 commit comments

Comments
 (0)