標題: 設計編譯器指令碼用以平行化 JavaScript 程式
JSMP: Enabling Parallel Programming in JavaScript with Directives
作者: 蔡志豪
游逸平
Tsai, Chih-Hao
You, Yi-Ping
資訊科學與工程研究所
關鍵字: JavaScript;編譯器指令碼;平行程式設計;JavaScript;Compiler Directives;Parallel Programming
公開日期: 2017
摘要: JavaScript 是一個有彈性、輕量的動態語言,它被廣泛的應用在現在的網頁應用程式,而且並不僅僅是用來輔助操作使用者介面,還被用來處理高密集運算的工作。然而雖然已經有很多最佳化技術包含即時編譯被套用在 JavaScript 引擎上,但在平行運算的部分還是落後其它語言許多。Web Worker 是一個方法可以有效利用多核心CPU,但 Web Worker 之間無法分享同一個記憶體物件,這導致共享記憶體的平行運算變得困難。 在本篇論文中,我們提出了一個 JavaScript 平行程式框架,可以使用編譯器指令碼來平行化 JavaScript 程式。我們實作了一個編譯器可以將標註指令碼的 JavaScript 程式轉換成可以運行在當今瀏覽器,以 Web Worker 為基礎的 JavaScript 程式。並且多虧了 SharedArrayBuffer,我們也提出了一個方法可以將 JavaScript 物件轉換成在 Web Worker 之間共享的物件。我們的實驗結果顯示,我們的框架可以有效加速已經存在的 JavaScript 程式。
JavaScript is a dynamic language that is designed to be flexible and light-weight. It is widely used in modern web applications not only for user interface manipulation but also computation-intensive tasks. Many optimization techniques, such as just-in-time compilation, were applied to JavaScript engines for better performance. However, JavaScript concurrency is less addressed in the literature. A standard way to utilize multi-core CPUs in JavaScript is using Web Worker, which is a message-passing-based API for spawning background scripts to achieve parallelism. Nevertheless, message passing can be more difficult to program than shared memory. In this paper, we present an API, called $JSMP$, which involves a set of compiler directives and runtime routines for JavaScript with compiler directives for shared memory multiprocessing programming in JavaScript. We implemented a compiler that translates directive-annotated JavaScript programs to Web Worker-based JavaScript programs, which can be executed in most modern web browsers and a runtime library for running JSMP routines. Our evaluation shown that the proposed framework enabled parallel processing of JavaScript programs on multi-core CPU architectures. Our framework improved the performance of JavaScript programs with an average of 2.8x (geometric mean) speedup on a quad-core processor.
URI: http://etd.lib.nctu.edu.tw/cdrfb3/record/nctu/#GT070356040
http://hdl.handle.net/11536/140343
顯示於類別:畢業論文