Performance and Memory Improvements in ART(Android O)

1.内存方面的优化

  • 通过JIT profile在compile程序时将经常使用的method放在一个page里(局部性原理),程序加载时也只加载经常使用的部分
Performance and Memory Improvements in ART(Android O)_第1张图片
Paste_Image.png
  • New Garbage Collector

concurrently compact前台和后台程序,region based,GC开始时会暂停一段时间,决定回收哪个region(source region,根据fragment percentage决定),扫描完程序的thread stack之后,程序thread继续运行。然后是copying phase,将reachable object 从source region拷贝到dest region,然后锁住source region,进行回收(reclaim)。

Performance and Memory Improvements in ART(Android O)_第2张图片
Paste_Image.png

为了防止在拷贝过程中,程序线程访问source region的object,由read barrier来拦截访问,同时把访问的object拷贝到dest region中,返回拷贝后的地址

Performance and Memory Improvements in ART(Android O)_第3张图片
Paste_Image.png

拷贝完成后,heap更加紧凑

Performance and Memory Improvements in ART(Android O)_第4张图片
Paste_Image.png

新的allocator

Performance and Memory Improvements in ART(Android O)_第5张图片
Paste_Image.png

2.Performance

  • Better inlining
Performance and Memory Improvements in ART(Android O)_第6张图片
Paste_Image.png
  • Code Sinking
Performance and Memory Improvements in ART(Android O)_第7张图片
Paste_Image.png
  • Class Hierarchy Analysis
Performance and Memory Improvements in ART(Android O)_第8张图片
Paste_Image.png
  • Loop Optimization
    找出Induction Variable
Performance and Memory Improvements in ART(Android O)_第9张图片
Paste_Image.png
Performance and Memory Improvements in ART(Android O)_第10张图片
Paste_Image.png
Performance and Memory Improvements in ART(Android O)_第11张图片
Paste_Image.png
Performance and Memory Improvements in ART(Android O)_第12张图片
Paste_Image.png
Performance and Memory Improvements in ART(Android O)_第13张图片
Paste_Image.png
Performance and Memory Improvements in ART(Android O)_第14张图片
Paste_Image.png

你可能感兴趣的:(Performance and Memory Improvements in ART(Android O))