JavaScript并行化性能提升的研究与实现
发布时间:2018-09-13 15:11
【摘要】:当前,脚本语言的执行速度是限制网络应用进一步发展的主要因素之一。JavaScript作为网络编程中主要使用的脚本语言,其性能提升对开发计算密集型Web应用意义重大。目前,针对JavaScript引擎优化的研究已经很多,而针对JavaScript语言本身的并行化性能提升却仍未出现完善的解决方案。本文针对这一新兴领域,从不同角度进行了研究与探索,对提高浏览器性能具有重要的实际意义。 本文首先介绍了JavaScript语言的特点与并行化编程的方法,并详细介绍了Chromium浏览器的多线程架构与沙箱机制。接着,本文以Chromium浏览器为载体,通过在WebKit引擎中新增模块的方式,设计并实现了基于WebKit的JavaScript并行化扩展,在JavaScript层进行函数解析和翻译,在C++层调用OpenCL库进行并行计算,并通过IDL语言将模块绑定到V8引擎。同时,本文针对网络语言的安全性和兼容性需求,对系统流程进行了调整与优化,在渲染进程启动初期完成环境预配置工作,以满足Chromium的沙箱模型,避免恶意代码的攻击;并对OpenCL链接库采用动态加载方式,,设计了完善的容错机制,确保系统能在不同的平台上编译与使用。 在实现了JavaScript并行扩展后,本文对JavaScript引擎内部机制进行了分析,基于V8引擎本身从另一角度进行了探索,设计了在V8内部实现JavaScript并行机制的整体框架与流程,改进了并行接口并设计了合适的数据分解模式。此外,本文为V8引擎增加了线程池模块,实现了主从线程的同步协作,并通过延迟创建线程的方式避免了不必要的系统开销。 最后,本文针对实现的JavaScript并行系统,通过实际的JavaScript程序进行了性能测试,并详细分析了处理器核心数目、数据规模、运行次数以及程序自身可并行程度对JavaScript并行化性能提升的影响,最后给出了本文实现的并行系统的使用场景。 本文实现的JavaScript并行化系统,能够显著提高计算密集型JavaScript程序的运行速度,帮助开发者编写具备更复杂能力的Web应用,提高用户体验,具有一定的实用价值。
[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.
【学位授予单位】:上海交通大学
【学位级别】:硕士
【学位授予年份】: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.
【学位授予单位】:上海交通大学
【学位级别】:硕士
【学位授予年份】:2014
【分类号】:TP393.092
【参考文献】
相关期刊论文 前6条
1 陈文宇;Windows编程中的面向对象技术[J];电子科技大学学报;2002年01期
2 陆云昆;余健;赵力;邹采荣;;嵌入式浏览器Konqueror/E的实现[J];电子产品世界;2006年21期
3 李晋惠;寇立涛;乔永兴;;用软件来提高多核处理器性能的方法分析[J];工业仪表与自动化装置;2010年01期
4 伊君翰;;基于多核处理器的并行编程模型[J];计算机工程;2009年08期
5 王华,马亮,顾明;线程池技术研究与应用[J];计算机应用研究;2005年11期
6 牛津;杨涛;王林;;网页浏览器内核的比较研究[J];微计算机应用;2009年03期
本文编号:2241537
本文链接:https://www.wllwen.com/guanlilunwen/ydhl/2241537.html