每日一練--為什么 ART 比 Dalvik 更好?

訂了個計劃,極可能每日翻譯一篇英文文檔。 優質的英文源不好找,想到Quora.com上面有很多不錯,就暫時先用這個來做吧。

Why is ART better than Dalvik?

為什么 ART 比 Dalvik 更好?


ART(Android RunTime) is the next version of Dalvik. Dalvik is the runtime, bytecode, and VM used by the Android system for running Android applications.

ART 是Dalvik的下一代版本,Dalvik 是安卓系統運行的 應用的 一個虛擬機。Dalvik是 運行時,和 字節碼。

ART has two main features compared to Dalvik:

ART比較 Dalvik 有兩個主要功能。

Ahead-of-Time (AOT) compilation, which improves speed (particularly startup time) and reduces memory footprint (no JIT)

AOT 編譯,可以提高速度(特別是啟動時間) 和 減少內存足跡(不是 JIT )

Improved Garbage Collection (GC)

改進 內存回收(GC)

AOT means your apps are compiled to native code once. What is stored on your phone and run is effectively native, not bytecode. This differs from the traditional VM model, which interprets bytecode. Interpreters are slow, so VM developers added a technology calledJust-in-Time(JIT) compilation, which compiles (and hopefully optimizes) your code to native code on-the-fly. Dalvik is a JIT'ing VM. The downside to JIT is that the JIT compiler runs while you are using your app, adding latency and memory pressure. The upside is that the JIT compiler can look athowyou are using your code to perform profile-directed optimizations.

AOT 意味著 一旦你的APP被編譯成原生代碼,那么存儲在手機或者運行的時候實際上都是原生的,不是字節碼。傳統的虛擬機模型 處理上是使用解釋 字節碼,然后解釋器運行時 比較慢的,因此 虛擬機 開發者,加入一個技術 Call/Just-In-Time(JIT)編譯。JIT 可以快速 編譯 (和希望 優化) 你的代碼成原生的代碼。Dalvik 是一種 JIT 同時進行的Vm。JIT的 最差表現是 進行JIT編譯的同時運行 你的APP,會有附加延遲和內存壓力。最佳性能是 JIT 編譯器可以 查找 你 如何使用你的代碼,來 執行 面向概要的 優化。

AOT is like JIT, but it runs once—say, at app installation time. While it lacks the ability to perform profile-directed optimizations, it is possible to perform more extensive optimizations since the compilation is less time sensitive. AOT is useful on systems, such as mobile devices, where JIT adds an unacceptable latency or memory cost to running apps. I think AOT is the right step for Android and ART looks quite impressive.

AOT 像JIT,但是 它一旦 運行(就是,APP 安裝的時候)。雖然 他缺少執行 面向概要的 優化,但是他可以執行更加廣泛的優化,因為編譯器有更多的時間來處理(對時間不敏感)。AOT 對 一些系統 有用(比如 手機設備),在這些系統上,JIT 可能會 增加 不可接受的延遲 和內存消耗來運行APP。我認為 AOP ?是 安卓 做的正確 優化(步驟),ART看起來令人印象深刻。

ART was first included inAndroid KitKat, but isn't yet enabled by default. You can enable it viaSettings>Developer options>Select runtime>Use ART.

ART 第一次是被 Android Kikat 引入,但是 默認 沒有啟用。 你可以啟用它通過 ?設置-》 開發者選項=》 選擇運行時=》 使用ART

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。