JavaScript并行化性能提升的研究與實(shí)現(xiàn)
發(fā)布時(shí)間:2018-09-13 15:11
【摘要】:當(dāng)前,腳本語言的執(zhí)行速度是限制網(wǎng)絡(luò)應(yīng)用進(jìn)一步發(fā)展的主要因素之一。JavaScript作為網(wǎng)絡(luò)編程中主要使用的腳本語言,其性能提升對開發(fā)計(jì)算密集型Web應(yīng)用意義重大。目前,針對JavaScript引擎優(yōu)化的研究已經(jīng)很多,而針對JavaScript語言本身的并行化性能提升卻仍未出現(xiàn)完善的解決方案。本文針對這一新興領(lǐng)域,從不同角度進(jìn)行了研究與探索,對提高瀏覽器性能具有重要的實(shí)際意義。 本文首先介紹了JavaScript語言的特點(diǎn)與并行化編程的方法,并詳細(xì)介紹了Chromium瀏覽器的多線程架構(gòu)與沙箱機(jī)制。接著,本文以Chromium瀏覽器為載體,通過在WebKit引擎中新增模塊的方式,設(shè)計(jì)并實(shí)現(xiàn)了基于WebKit的JavaScript并行化擴(kuò)展,在JavaScript層進(jìn)行函數(shù)解析和翻譯,在C++層調(diào)用OpenCL庫進(jìn)行并行計(jì)算,并通過IDL語言將模塊綁定到V8引擎。同時(shí),本文針對網(wǎng)絡(luò)語言的安全性和兼容性需求,對系統(tǒng)流程進(jìn)行了調(diào)整與優(yōu)化,在渲染進(jìn)程啟動(dòng)初期完成環(huán)境預(yù)配置工作,以滿足Chromium的沙箱模型,避免惡意代碼的攻擊;并對OpenCL鏈接庫采用動(dòng)態(tài)加載方式,,設(shè)計(jì)了完善的容錯(cuò)機(jī)制,確保系統(tǒng)能在不同的平臺上編譯與使用。 在實(shí)現(xiàn)了JavaScript并行擴(kuò)展后,本文對JavaScript引擎內(nèi)部機(jī)制進(jìn)行了分析,基于V8引擎本身從另一角度進(jìn)行了探索,設(shè)計(jì)了在V8內(nèi)部實(shí)現(xiàn)JavaScript并行機(jī)制的整體框架與流程,改進(jìn)了并行接口并設(shè)計(jì)了合適的數(shù)據(jù)分解模式。此外,本文為V8引擎增加了線程池模塊,實(shí)現(xiàn)了主從線程的同步協(xié)作,并通過延遲創(chuàng)建線程的方式避免了不必要的系統(tǒng)開銷。 最后,本文針對實(shí)現(xiàn)的JavaScript并行系統(tǒng),通過實(shí)際的JavaScript程序進(jìn)行了性能測試,并詳細(xì)分析了處理器核心數(shù)目、數(shù)據(jù)規(guī)模、運(yùn)行次數(shù)以及程序自身可并行程度對JavaScript并行化性能提升的影響,最后給出了本文實(shí)現(xiàn)的并行系統(tǒng)的使用場景。 本文實(shí)現(xiàn)的JavaScript并行化系統(tǒng),能夠顯著提高計(jì)算密集型JavaScript程序的運(yùn)行速度,幫助開發(fā)者編寫具備更復(fù)雜能力的Web應(yīng)用,提高用戶體驗(yàn),具有一定的實(shí)用價(jià)值。
[Abstract]:At present, the execution speed of scripting language is one of the main factors restricting the further development of network applications. JavaScript is the main scripting language used in network programming, and its performance improvement is of great significance to the development of computation-intensive Web applications. At present, there have been a lot of researches on JavaScript engine optimization, but there are still no perfect solutions to improve the parallelization performance of JavaScript language itself. This paper studies and explores this new field from different angles, which has important practical significance for improving browser performance. This paper first introduces the characteristics of JavaScript language and the method of parallel programming, and introduces in detail the multithreading architecture and sandbox mechanism of Chromium browser. Then, by using Chromium browser as carrier and adding new modules in WebKit engine, this paper designs and implements JavaScript parallelization extension based on WebKit, parses and translates functions in JavaScript layer, and calls OpenCL library in C layer for parallel computation. The module is bound to V8 engine by IDL language. At the same time, this paper adjusts and optimizes the system flow according to the security and compatibility requirements of the network language, completes the environment pre-configuration work in the initial stage of the rendering process, in order to satisfy the sandbox model of Chromium and avoid the malicious code attack; The OpenCL link library is dynamically loaded and a perfect fault-tolerant mechanism is designed to ensure that the system can be compiled and used on different platforms. After implementing the JavaScript parallel extension, this paper analyzes the internal mechanism of the JavaScript engine, explores the V8 engine itself from another angle, and designs the whole framework and process of implementing the JavaScript parallel mechanism in the V8 engine. The parallel interface is improved and a suitable data decomposition mode is designed. In addition, this paper adds thread pool module to V8 engine, realizes synchronous cooperation between master and slave threads, and avoids unnecessary system overhead by delaying the creation of threads. Finally, the performance of the implemented JavaScript parallel system is tested by the actual JavaScript program, and the processor core number and data scale are analyzed in detail. The effect of running times and the degree of parallelism of program itself on the performance improvement of JavaScript parallelization is discussed. Finally, the use scenario of the parallel system implemented in this paper is given. The JavaScript parallelization system implemented in this paper can significantly improve the running speed of computation-intensive JavaScript programs, help developers to write more complex Web applications, and improve the user experience. It has certain practical value.
【學(xué)位授予單位】:上海交通大學(xué)
【學(xué)位級別】:碩士
【學(xué)位授予年份】:2014
【分類號】:TP393.092
本文編號:2241537
[Abstract]:At present, the execution speed of scripting language is one of the main factors restricting the further development of network applications. JavaScript is the main scripting language used in network programming, and its performance improvement is of great significance to the development of computation-intensive Web applications. At present, there have been a lot of researches on JavaScript engine optimization, but there are still no perfect solutions to improve the parallelization performance of JavaScript language itself. This paper studies and explores this new field from different angles, which has important practical significance for improving browser performance. This paper first introduces the characteristics of JavaScript language and the method of parallel programming, and introduces in detail the multithreading architecture and sandbox mechanism of Chromium browser. Then, by using Chromium browser as carrier and adding new modules in WebKit engine, this paper designs and implements JavaScript parallelization extension based on WebKit, parses and translates functions in JavaScript layer, and calls OpenCL library in C layer for parallel computation. The module is bound to V8 engine by IDL language. At the same time, this paper adjusts and optimizes the system flow according to the security and compatibility requirements of the network language, completes the environment pre-configuration work in the initial stage of the rendering process, in order to satisfy the sandbox model of Chromium and avoid the malicious code attack; The OpenCL link library is dynamically loaded and a perfect fault-tolerant mechanism is designed to ensure that the system can be compiled and used on different platforms. After implementing the JavaScript parallel extension, this paper analyzes the internal mechanism of the JavaScript engine, explores the V8 engine itself from another angle, and designs the whole framework and process of implementing the JavaScript parallel mechanism in the V8 engine. The parallel interface is improved and a suitable data decomposition mode is designed. In addition, this paper adds thread pool module to V8 engine, realizes synchronous cooperation between master and slave threads, and avoids unnecessary system overhead by delaying the creation of threads. Finally, the performance of the implemented JavaScript parallel system is tested by the actual JavaScript program, and the processor core number and data scale are analyzed in detail. The effect of running times and the degree of parallelism of program itself on the performance improvement of JavaScript parallelization is discussed. Finally, the use scenario of the parallel system implemented in this paper is given. The JavaScript parallelization system implemented in this paper can significantly improve the running speed of computation-intensive JavaScript programs, help developers to write more complex Web applications, and improve the user experience. It has certain practical value.
【學(xué)位授予單位】:上海交通大學(xué)
【學(xué)位級別】:碩士
【學(xué)位授予年份】:2014
【分類號】:TP393.092
【參考文獻(xiàn)】
相關(guān)期刊論文 前6條
1 陳文宇;Windows編程中的面向?qū)ο蠹夹g(shù)[J];電子科技大學(xué)學(xué)報(bào);2002年01期
2 陸云昆;余健;趙力;鄒采榮;;嵌入式瀏覽器Konqueror/E的實(shí)現(xiàn)[J];電子產(chǎn)品世界;2006年21期
3 李晉惠;寇立濤;喬永興;;用軟件來提高多核處理器性能的方法分析[J];工業(yè)儀表與自動(dòng)化裝置;2010年01期
4 伊君翰;;基于多核處理器的并行編程模型[J];計(jì)算機(jī)工程;2009年08期
5 王華,馬亮,顧明;線程池技術(shù)研究與應(yīng)用[J];計(jì)算機(jī)應(yīng)用研究;2005年11期
6 牛津;楊濤;王林;;網(wǎng)頁瀏覽器內(nèi)核的比較研究[J];微計(jì)算機(jī)應(yīng)用;2009年03期
本文編號:2241537
本文鏈接:http://sikaile.net/guanlilunwen/ydhl/2241537.html
最近更新
教材專著