Facebook Redex实践

作者: 嘟嘟噜噜可 | 来源:发表于2016-04-14 14:10 被阅读684次

一,环境配置

1,github地址:https://github.com/facebook/redex

2,环境配置中可能遇到的问题:

python3安装,错误如下图:python already installed, it's just not linked

Paste_Image.png

执行brew link python3,继续错误:Permission denied

执行brew doctor分析:

Paste_Image.png

Warning: python3-3.5.0 already installed, it's just not linked

Paste_Image.png

根据提示,执行下面的命令:

Paste_Image.png

Note:
由于redex刚开源,代码存在一定问题,我使用的commit id是
commit eed0e312ac341aa34e8bab8a53ddcbfc062784cc

二,Redex的原理:

https://code.facebook.com/posts/1480969635539475/optimizing-android-bytecode-with-redex

简言之:

1,将通用路径用简短的字符串代替

2,inline (内联)
2-1 合并方法
2-2 优化父子类之间的调用

什么是inline?
http://www.deepinmind.com/java/2014/03/01/JVM%E7%9A%84%E6%96%B9%E6%B3%95%E5%86%85%E8%81%94.html

Note:JVM会在运行时优化,Redex在dex中优化。

三,优化效果

Paste_Image.png

apk大小减小了7.1%

四,存在问题

如何将线上问题映射为正确的代码,帮助定位线上crash问题

相关文章

网友评论

    本文标题:Facebook Redex实践

    本文链接:https://www.haomeiwen.com/subject/xnpglttx.html