Title: | 廣藿香: 將x86可執行碼轉成網路應用程式的智慧型二元碼轉譯框架 Patchouli: A Knowledge-Based Translation Framework for x86 Binary to Web Applications |
Authors: | 劉弘威 單智君 Liu, Hong-Wei Shann, Jyh-Jiun 資訊科學與工程研究所 |
Keywords: | 二元轉譯技術;網路程式;虛擬化技術;binary translation;web application;virtualization |
Issue Date: | 2016 |
Abstract: | 計算機網路已不再只是功能取向的工具,亦是構成現代文明的重要推手。主要原因在於網路上資訊(information)散播的速度遠超過傳統媒體,且流通的資料(Data)量亦遠多於傳統資料儲存裝置。為了適應網路的可攜性(portability),許多伺服器會利用網路應用程式(web application)來協助或是完成其所需要提供的服務。目前網路應用程式之開發以腳本語言(Script language)為大宗。然而,腳本語言所開發之程式雖擁有高可攜性,但其執行效能之低落亦為人所詬病。與傳統的桌上型程式(desktop application)相比,網路程式的數量以及種類也相對較少。這些缺點將直接或間接影響到每個伺服器所能提供之服務的質與量。 為了改善網路程式的效能以及提升網路程式的數量,谷歌(Google)公司於2008年提出Native Client (簡稱NaCl)計畫,運用沙盒(sandbox)技術使本地碼(native code)可以安全並快速地直接在瀏覽器(browser)上執行。2010年,谷歌公司再推出Portable Native Client (簡稱PNaCl)計畫,使用中間碼(intermediate representation,IR)來當作傳遞的媒介,以提升程式的可攜性。本篇研究將結合二元轉譯(binary translation)技術以及沙盒技術,使傳統桌上型x86可執行檔能透過PNaCl系統在網路上安全且有效率地執行。在保有本地碼執行效能之優勢與透過網際網路達到高傳播效率的同時,我們亦設計出一個能利用蒐集自全世界客戶端(client)的側寫資料(profiling data),以不斷改善轉譯品質的二元碼轉譯框架(binary translation framework)。 為了完成這個框架,本篇研究將修改一個既有的二元碼轉譯器(binary translator),將之與PNaCl系統整合,並設計側寫管理機制。此二元碼轉譯框架的設計與實作主要分為三大部分:第一、改善二元碼轉譯器,以增加轉譯碼(translated code)的品質與可攜性;第二、修改轉譯碼與本地作業系統(host operating system)之間的仿真單元(Emulation runtime),使轉譯碼可順利地在PNaCl平台上執行。第三、開發新的側寫資料管理器(Profiling-Data Manager ),以分析並運用蒐集自客服端的大量側寫資料。 實驗結果顯示,修改後的x86二元轉譯器將一既有的x86可執行檔所轉譯出的轉譯碼大小,平均約為原來轉譯器產生的30%。此外,我們能利用近乎無負擔的側寫機制,獲取程式動態執行時完整的記憶體指令存取區域相關資訊;而後,可將相同的可執行檔再次轉譯,轉譯後的二元碼大小可再減少,平均為原來轉譯器的21%。在效能方面,與來源碼(source code)在本地環境(native platform)下之執行情況相較,再次轉譯的x86二元碼轉換成nexe後,可在僅損失50%的效能下順利地在瀏覽器中的NaCl系統上仿真執行。 Computer Network is not only a tool, but also one of the important roles on advancing modern civilization. Two main reasons are that the speed of spread and the amount of data through computer networking are much faster and greater than traditional media. To utilize the portability of computer network, many servers have used web applications to assist or accomplish their services. Most of the web applications are developed by script languages, and thereby, these applications usually have high portability and compatibility. However, script language is a kind of dynamic language and thus incurs poor performance. Moreover, compare to desktop applications, web applications lack variety. These drawback will decrease the quantity and quality of service provided by servers. To enhance the performance and increase the variety of web applications, Google Inc. released a new project named Native Client (NaCl) in 2008, which is a sandboxing technology for running a native code on web browser. In 2010, Google released another project named Portable Native Client (PNaCl), which is an architecture-independent version of NaCl for higher portability. In this thesis, we integrate a binary translator and the PNaCl system for translating legacy x86 executables to web applications. In the meantime, the high portability and usability of web applications inspire us to develop a new profiling strategy to collect and analyze the profiling data from worldwide clients for improving the translation quality further. To accomplish our framework, we modify an existing binary translator, SBT86, integrate it with PNaCl system, and design a global profiling strategy. Implementations of this framework are divided into three parts. First, for enhancing the translation quality and portability of the translated code, we modify the translation functions and helper functions of SBT86. Second, for executing translated code on PNaCl system, we modify the interface between the host operation system and the translated code. Third, we design a Profiling-Data Manager for analyzing the big profiling data. Our experiments show that our modification of previous x86 binary translator reduces the size of the translated code of legacy x86 executable for 70% on average. At the meantime, we may collect memory-related profiling data and then improve our translated code further with lightweight overhead for each user. After that, our framework will utilize the profiling data to retranslate the executable with aggressive optimization. Finally, we can reduce the size of the translated code for 79% on average, and the emulation of the legacy x86 executable on NaCl system may lose only 50% performance comparing with execution time of the source executable on naitve platform. |
URI: | http://etd.lib.nctu.edu.tw/cdrfb3/record/nctu/#GT070156100 http://hdl.handle.net/11536/140144 |
Appears in Collections: | Thesis |