TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Improving Facebook's Performance on Android with FlatBuffers

129 点作者 numo16将近 10 年前

15 条评论

rquirk将近 10 年前
The FlatBuffers repo on github continues a couple of &quot;meta-trends&quot; I&#x27;ve noticed in recent Google projects. <a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;flatbuffers" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;flatbuffers</a><p>First, it uses CMake to build - for a long time Google projects had seemed pretty anti-CMake (for example using gyp, plain Makefiles or autotools) so it&#x27;s nice to see them using CMake. IMO it&#x27;s the best build tool, though all build tools generate various levels of hate :-)<p>Second it&#x27;s another Google project that generates good developer docs from source code using doxygen and markdown. These docs look good on github directly (<a href="https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;flatbuffers&#x2F;tree&#x2F;master&#x2F;docs&#x2F;source" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;google&#x2F;flatbuffers&#x2F;tree&#x2F;master&#x2F;docs&#x2F;sourc...</a>) as they are markdown, and even better on the dedicated site where they have custom css.<p>If I were to write a C++ library, I&#x27;d definitely copy these 2 approaches.
评论 #9988169 未加载
acqq将近 10 年前
In short: They first used JSON, if I understood correctly. Then<p>&quot;In last six months, we have transitioned most of Facebook on Android to use FlatBuffers as the storage format. Some performance improvement numbers include:<p>Story load time from disk cache is reduced from 35 ms to 4 ms per story.<p>Transient memory allocations are reduced by 75 percent.<p>Cold start time is improved by 10-15 percent.<p>We have reduced storage size by 15 percent.&quot;
评论 #9986164 未加载
评论 #9986114 未加载
suyash将近 10 年前
For those are are totally new to Flatbuffers, here is a good video by Colt from Google. It was primarily created for game developers but technically any app can use it - those who are not relying on a library that handles networking and has implementation for JSON.<p>He also mentioned Flatbuffer use in his recent at Android meetup in San Francisco and we debated it&#x27;s benefits again. It has a learning curve but well worth it: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=iQTxMkSJ1dQ" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=iQTxMkSJ1dQ</a>
guymcarthur将近 10 年前
OK, so if I understand this correctly, a binary format where you can seek to arbitrary positions to read only the data you need to currently display is a huge performance win versus a big blob of text you have to read and fully parse. As someone who has had to uninstall FaceBook from my Android phone due to its poor performance, excuse me if I&#x27;m bewildered that they didn&#x27;t realize this years ago (FlatBuffers isn&#x27;t the first binary serialization format) and write it that way in the first place!
评论 #9985799 未加载
评论 #9988180 未加载
评论 #9986613 未加载
rw将近 10 年前
I liked this writeup. I&#x27;m curious how much this improved battery life for a typical user.<p>FWIW, I help maintain FlatBuffers for Go and Python. I&#x27;m happy to answer any questions I can.
评论 #9985702 未加载
评论 #9985478 未加载
oautholaf将近 10 年前
Not only can JSON be slow, SQLite has been shown be very problematic as well: <a href="http:&#x2F;&#x2F;0b4af6cdc2f0c5998459-c0245c5c937c5dedcca3f1764ecc9b2f.r43.cf2.rackcdn.com&#x2F;11774-atc13-jeong.pdf" rel="nofollow">http:&#x2F;&#x2F;0b4af6cdc2f0c5998459-c0245c5c937c5dedcca3f1764ecc9b2f...</a><p>The filesystem is a fantastic way to persist data for 80-90% of mobile applications.
评论 #9985984 未加载
vvanders将近 10 年前
They are missing the second major reason why flatbuffers is awesome, cache locality.<p>It&#x27;s incredibly hard to layout objects in memory with Java but if you don&#x27;t mind the lookup hit on bytebuffers flatbuffers is a great way to structure data in the patterns you access it.<p>All this stuff is pretty old-hat to game dev people bit it&#x27;s nice to see mainstream dev start caring a bit more about performance.
评论 #9988211 未加载
评论 #9986649 未加载
fmela将近 10 年前
Nice to see Facebook acknowledge contributions from Google. It&#x27;s a departure from typical not-invented-here mentality prevalent at large tech companies.
x0054将近 10 年前
What does the iOS Facebook app uses? Couldn&#x27;t be core data based on the fact that they claim they can not normalize the data ahead of time. The iOS app is nice and snappy, at least on my phone, though it does take some time to load.
mahyarm将近 10 年前
How much binary size does it consume? Have an app with 100 objects with a few thousand fields total and you have several megabytes consumed by protobuf alone. With 3mb source files if you put it all in one proto file.
brainburn将近 10 年前
I&#x27;m a bit surprised they decoded json on the main thread...
评论 #10016392 未加载
HaloZero将近 10 年前
I&#x27;m curious is Facebook working on a version for Obj-C &#x2F; Swift or do the iOS and Android clients now get back different types of results?
评论 #9985652 未加载
randyrand将近 10 年前
Funny how similar this is to just a simple filesystem.
评论 #9985041 未加载
bozoUser将近 10 年前
Why is this only for Android? Is that because of JIT compiler or is it an issue even on JVM and hence can we use flatbuffers even on web?
评论 #9985869 未加载
评论 #9988222 未加载
rubenfonseca将近 10 年前
So they&#x27;re telling me that they have all this multi-gazillion-CPU-core Android devices, but they parse JSON on the main thread?