怎样优化app,看Facebook怎样做
周四,Facebook Engineering blog 发表了一篇名为《Improving Facebook on Android》博文。博文从四个方面(Performance,Data
Efficiency,
Networking,Application Size)讲述了Facebook是怎样优化app保证其在不同国家不同类型Android设备上都能表现出良好性能的。
因为原文内容比較
easy理解,这里就直接给出原文。以使上边链接打不开的同学也能看到。《菜鸟成长史:http://blog.csdn.net/zjbpku》
In an effort to connect the next five billion, Facebook began to shift to a mobile-first company about
two years ago. We trained hundreds of employees on mobile development, restructured internal
teams to build for all platforms, and moved to a fast-paced release cycle.
However, our mission extends far beyond building and delivering the best experience on high-end
smartphones and LTE networks. We want Facebook to work for everyone – no matter the region,
network condition, or mobile device.
To help accomplish this goal, a team of product managers and engineers traveled to Africa to
examine mobile performance in developing countries. We purchased several different Android
handsets to test the latest version of the Facebook app – and the testing process proved to be
difficult. The combination of an intermittent, low-bandwidth network connection and a lack of
memory space on the devices resulted in slow load times and constant crashes. We even burned
through our monthly data plans in 40 minutes.We returned to our offices in Seattle, London, and
Menlo Park determined to enhance theFacebook experience on Android – and soon made major improvements
in performance, data efficiency, networking, and application size.
Performance
In terms of performance, we wanted to improve slow start times on old devices. In the beginning,
we focused on instrumenting the startup path and understanding the bottlenecks. There was no
silver bullet in this process – we needed to carefully identify and remove each potential bottleneck.
For example, we found that start times were slower on single-core devices because too many
features concurrently initialized themselves on application startup. We made sure to defer these
initializations until after startup and, in some cases, until the features are used.
We also wanted the stories in News Feed to load faster. In order to rapidly display cached content
on poor networks, we now fetch stories earlier in the process to allow more time to set up
connections and download News Feed. The cold start path has been automated to ensure that we
prevent further regressions in these areas.These changes reduced start times by more than 50 percent
in the six months following the trip to Africa.
Data efficiency
Next, we realized that data is extremely expensive in emerging markets, and purchasing more
data is often a laborious process. Thus, there needed to be a concerted effort to reduce data
consumption within the Facebook app. Interacting with photos is an important part of the
Facebook experience, but it takes a sizable amount of data to download them. If we could
optimize the download size, we could improve data savings and perceived app performance.
First, we investigated the use of alternative compression formats for image transmission. We built
tools to evaluate the impact of several different compression formats on data sizes and eventually
settled on WebP. It offered both great compression performance and efficient support from
Android. The use of WebP for transmitting Facebook images resulted in data savings of 25 to 35
percent compared with JPG, and 80 percent compared with PNG. This all happened without perceived
impact on quality.The next step was to work on loading images at a resolution that devices had the
ability to handle.In the past, we loaded images at maximum resolution to allow for the zoom-in feature.
However,on these kinds of devices this feature was used infrequently. We changed the process of loading
images to only request resolutions equivalent to the size of the viewport in which the images will
appear. Instead of loading a full image, the device only loads the image it needs to show (such as
a thumbnail, preview, or full image at lower resolution). Of course, if someone wants to zoom-in
on an image, we then download a higher resolution image.Finally, we looked over the process used to
cache and reuse images. We tested a number of potential caching strategies, as well as sizes for our
caches, and fine-tuned both to minimize the evictions for images that could be accessed again.
As was the case with performance, it was important to avoid regressing our data efficiency in the
future. We built automated tests and an elaborate system that can attribute data usage to
individual features. This allows Facebook features to understand their data usage in production
and make adjustments if it increases unexpectedly.The work on data efficiency resulted in a 50 percent
reduction in data use compared with earlier last year.
Networking
We also invested heavily in improving the efficiency and reliability of our networking stack. It was
important to implement more modern networking concepts in emerging markets because our
stacks struggled to perform in regions with intermittent networks.
Facebook was an early adopter of OkHttp, a networking stack open-sourced by Square, and it’s
now the stack used by the Android app. OkHttp allows us to support fast retries for intermittent
network situations, take advantage of the SPDY protocol for faster concurrent network
transmissions, and enable powerful instrumentation across the networking stack.
After switching to OkHttp, it became a goal to decrease the number of reports regarding failed
image loads in News Feed. We fine-tuned our image pre-fetching algorithms and altered the
process through which we queue images for download. The process now ensures that the
images expected to be downloaded next are prioritized in the queue and that no images are stuck
in the queue for too long.In combination with better data usage for images, reports of slow or failed
image loads dropped by almost 90 percent over the past year.
Application size
The most popular mobile devices in Africa have little disk space available, which is a significant
barrier to installing app upgrades. This means that people in developing countries often use older
versions of the app that don’t have up-to-date features or take advantage of the improvements
described in this blog post.Our colleagues in the Facebook London office focused on improving app
size efficiency. They approached this problem by utilizing Google Play’s ability to upload multiple
APKs for different Android OSes and screen resolutions. This allows us to exclude excess code for features or
resources not supported on certain mobile devices.As with the other areas, instrumentation and testability
were important to making sure we could bring the app size down. We now have tools that calculate how
each feature contributes to app size and analyze device size regressions.In the end, the app size has
been reduced by 65 percent compared with the beginning of the year.
What comes next?
Our trip to Africa really highlighted the importance of our work on mobile performance, data
efficiency, networking reliability, and application size for emerging markets. We’ve made a
concerted effort to improve in all these areas and achieved a significant amount of success in the
past year.
The lessons learned have already impacted the development of new features. We test all major
features and changes in poor networking scenarios. We have automated verification for various
performance and efficiency characteristics, which allows the features team to receive immediate
feedback on the impact of their code. We also expanded our playbook to other apps, such as
Messenger and Instagram.We will continue to innovate to make the Facebook experience better in emerging
markets, and share tools and information that can help developers build apps that work well on different
handsets, network environments, and operating systems.
注:以上英文内容来自:Facebook Code https://code.facebook.com/posts/485459238254631/improving-facebook-on-android/
怎样优化app,看Facebook怎样做的更多相关文章
- 优化 App 的启动时间
这是一篇 WWDC 2016 Session 406 的学习笔记,从原理到实践讲述了如何优化 App 的启动时间. App 运行理论 main() 执行前发生的事 Mach-O 格式 虚拟内存基础 M ...
- WWDC2018 之 优化 App Assets Optimizing App Assets
该篇博客记录了观看WWDC Session227<Optimizing App Assets>的内容以及一些理解. 引言 该session主要讲述了使用Assets Catalog的新特性 ...
- 5个可以帮你优化App的优秀网站
也许现在有一款App可以提供所有你需要的,你不需要的,或者你可以想象到的内容.但是,有多少App真的可以不仅满足需求而且还能提供很好的用户体验呢? 相信很多APP并没有这样的能力.有一些APP的设计特 ...
- Android性能优化-App后台优化
原文链接 Background Optimizations 前言 后台进程是内存和电池敏感的.一个隐式的broadcast可能会启动很多监听它的后台进程,即使这些进程可能做得工作不多.这可能丢设备性能 ...
- Android性能优化-App启动优化
原文地址:https://developer.android.com/topic/performance/launch-time.html#common 通常用户期望app响应和加载速度越快越好.一个 ...
- IOS-5个可以帮你优化App的优秀网站
也许现在有一款App可以提供所有你需要的,你不需要的,或者你可以想象到的内容.但是,有多少App真的可以不仅满足需求而且还能提供很好的用户体验呢? 相信很多APP并没有这样的能力.有一些APP的设计特 ...
- 涉嫌垄断的App Store,到底做了什么让开发者暴怒
Store,到底做了什么让开发者暴怒" title="涉嫌垄断的App Store,到底做了什么让开发者暴怒"> 什么行业最赚钱?不是你想象中的餐饮.互联网. ...
- 小师妹学JVM之:深入理解JIT和编译优化-你看不懂系列
目录 简介 JIT编译器 Tiered Compilation分层编译 OSR(On-Stack Replacement) Deoptimization 常见的编译优化举例 Inlining内联 Br ...
- [转]Code! MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on (C#)
本文转自:https://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-o ...
随机推荐
- C++关于运算符的注意事项
1.函数调用也是一种特殊的运算符,对运算对象的个数不作限制. 2.几元运算符,是基于作用的对象的数量. 3.不同类型的运算对象进行运算,可能会出现类型转换,一般情况下小整数类型会被转换成较大的整数类型 ...
- Iterator 与ListIterator的区别
Iterator 与ListIterator的区别: 1.Iterator能够迭代Set和List集合的元素,而ListIterator只能迭代List集合的元素 2.Iterator只能前向迭代,L ...
- SQL-7查找薪水涨幅超过15次的员工号emp_no以及其对应的涨幅次数t (group 与count)
题目描述 查找薪水涨幅超过15次的员工号emp_no以及其对应的涨幅次数tCREATE TABLE `salaries` (`emp_no` int(11) NOT NULL,`salary` int ...
- 7series 逻辑单元理解(更新中)
7series 逻辑单元理解 ug768和ug799文档介绍了7系列芯片中包含的基本逻辑单元,对其中常用的单元,进行下分析. 1.IOBUF单元 (1)真值表 (2)用途 the design e ...
- DevExpress v18.1新版亮点——Reporting篇(四)
用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress Reporting v18.1 的新功能,快来下载试用新版本 ...
- django面试五
http和https的区别https协议需要到ca申请证书,一般免费证书很少,需要交费. 注:CA - certificate authority,身份认证,权威机构认证,CA认证: http是超文本 ...
- python 读写、创建 文件的方法(必看)
python 读写.创建 文件的方法(必看) 更新时间:2016年09月12日 10:26:41 投稿:jingxian 我要评论下面小编就为大家带来一篇python 读写.创建 文件的方法(必看). ...
- 线程简述(Thread)
线程: 进程是一个正在运行的程序,例如电脑上现在在运行的qq,浏览器,电脑管家,这些都是进程 线程就是每一个进程中的一个执行单元,每一个进程至少一个线程,可以有多个线程,例如浏览器上每一个打开的网页都 ...
- python第二天 python介绍与变量
编程语言的分类: 分别为 机器语言,汇编语言,高级语言 所以按照翻译方式又被分为两种 编译型:在代码执行时,需要先进行编译成二进制文件之后,才能够被执行 代表如:c语言,执行速度快,但是调试麻烦 解释 ...
- HDU 1205 吃糖果(想想题)
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=1205 Problem Description HOHO,终于从Speakless手上赢走了所有的糖果, ...