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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

LightSpeed: Rewriting Messenger’s codebase for a faster, smaller, simpler app

401 点作者 moneil971大约 5 年前

55 条评论

butz大约 5 年前
The loop of app building: 1. Build app with native framework. 2. Re-build app with some alternative framework which is slower, but let's you deploy single code on all platforms. 3. Re-build app with native framework, because it is faster. 4. GOTO 2
评论 #22470178 未加载
评论 #22471351 未加载
评论 #22470394 未加载
评论 #22470324 未加载
评论 #22469367 未加载
评论 #22470646 未加载
评论 #22469661 未加载
评论 #22472071 未加载
评论 #22473564 未加载
评论 #22471663 未加载
评论 #22471278 未加载
评论 #22469102 未加载
millstone大约 5 年前
From <a href="https:&#x2F;&#x2F;engineering.fb.com&#x2F;data-infrastructure&#x2F;messenger&#x2F;" rel="nofollow">https:&#x2F;&#x2F;engineering.fb.com&#x2F;data-infrastructure&#x2F;messenger&#x2F;</a>:<p><i>Rather than reinventing the wheel, we used the UI framework available on the device’s native OS to support a wider variety of application feature needs. This reduced not only size, by avoiding the need to cache&#x2F;load large custom-built frameworks, but also complexity. The native frameworks don’t have to be translated into sub-frameworks. We also used quite a few of the OS libraries, including the JSON processing library, rather than building and storing our own libraries in the codebase.</i><p>This is awesome. It shows the benefits of building an app leveraging the OS, instead of fighting or abstracting it.
评论 #22468632 未加载
评论 #22472187 未加载
评论 #22469452 未加载
danabramov大约 5 年前
Quite a few comments seem to imply Messenger was written in React Native, so I want to clarify this is not true. Messenger was a fully native app before the rewrite, too!<p>RN isn’t the right tradeoff for Messenger — whose new core is written in plain C — but its use at FB in general is growing, with 750+ screens in RN. So the rumours of its death are greatly exaggerated.<p>I think it’s great to have different options with different tradeoffs available to choose from. But hey, that’s just me.
评论 #22475608 未加载
aldanor大约 5 年前
So, they&#x27;ve reduced 1.7M lines of code to 360K. Let&#x27;s pause here for a moment:<p>- NumPy is 360K lines mostly C<p>- Postgres is around 2.1M of C<p>- Go 1.13 is around 1.5M of Go code<p>- Rust 1.37 is around 1.2M of Rust code iirc<p>- core llvm is around 3M of C++ iirc<p>...<p>A chat app is 1.7M. A chat app...<p>Makes me feel sorry for all the time spent&#x2F;wasted by all those devs, many of whom are unquestionably brilliant and could&#x27;ve worked together on something truly awesome, big and useful. But we all know that doesn&#x27;t pay the bills and so here we are.
评论 #22469164 未加载
评论 #22469602 未加载
评论 #22470626 未加载
评论 #22469034 未加载
评论 #22473281 未加载
评论 #22469185 未加载
评论 #22469504 未加载
评论 #22469021 未加载
评论 #22469030 未加载
评论 #22470416 未加载
评论 #22493678 未加载
评论 #22470400 未加载
评论 #22479426 未加载
评论 #22471762 未加载
评论 #22469037 未加载
reggieband大约 5 年前
From: <a href="https:&#x2F;&#x2F;engineering.fb.com&#x2F;data-infrastructure&#x2F;messenger&#x2F;" rel="nofollow">https:&#x2F;&#x2F;engineering.fb.com&#x2F;data-infrastructure&#x2F;messenger&#x2F;</a><p>&gt; We accomplished this by using the native OS wherever possible<p>Does this mean this application does not use React Native?
评论 #22468724 未加载
评论 #22468250 未加载
评论 #22472293 未加载
评论 #22468251 未加载
评论 #22468575 未加载
评论 #22468507 未加载
评论 #22468157 未加载
评论 #22468163 未加载
评论 #22469111 未加载
评论 #22468468 未加载
评论 #22468706 未加载
评论 #22469358 未加载
评论 #22468204 未加载
评论 #22468215 未加载
currysausage大约 5 年前
&quot;We started with the premise that Messenger needed to be a simple, lightweight utility. Some apps are immersive (video streaming, gaming); people spend hours using them. Those apps take up a lot of storage space, battery time, etc., and the trade-off makes sense. But messages are just tiny snippets of text that take less than a second to send. Fundamentally, a messaging app should be one of the smallest, lightest-weight apps on your phone. With that principle in mind, we began looking at the right way to make our iOS app significantly smaller.&quot;<p>This paragraph just restored my faith in developer sanity.
jascii大约 5 年前
Old joke:<p>Every program can be (memory)optimized by at least one byte and has at least one bug in it.<p>It therefore follows that every program can be reduced to a single byte that doesn&#x27;t work.
dean177大约 5 年前
&gt; We extended SQLite with the capability of stored procedures, allowing Messenger feature developers to write portable, database-oriented business logic<p>I wish the article was a little more fleshed out, I&#x27;d be interested in finding out more about how and why they went down this path
评论 #22468868 未加载
gagabity大约 5 年前
Keep seeing react native pop up in the comments, there has never been any indication that Messenger used any react native from fb feom all their presentations I have see . RN is used in the Marketplace tab on the Facebook App, the Ad manager app and a few other places.
评论 #22473226 未加载
vodkaPong大约 5 年前
The architecture they have ended up with is similar to that described in Out of the Tar Pit, which describes how to remove as much complexity from software as possible.<p>By moving all state into SQLite they have implemented the &quot;store state in relations&quot; layer, and then written (as far as possible) functional code on top.<p>I&#x27;ve been thinking about how to make my software more like this so it&#x27;s interesting to see Facebook are thinking along the same lines.<p>There&#x27;s a lot of really good ideas in Out of the Tar Pit and I&#x27;d really recommend reading it.
评论 #22478900 未加载
monocasa大约 5 年前
Considering that they were shipping 18,000 classes in their iOS app back in 2015, a quarter the size of their 2019 app has to be still unreasonably massive.<p><a href="https:&#x2F;&#x2F;gist.github.com&#x2F;quellish&#x2F;473f513fbd1310233a8e" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;quellish&#x2F;473f513fbd1310233a8e</a>
评论 #22469481 未加载
评论 #22469458 未加载
AWebOfBrown大约 5 年前
I thought Messenger was ReasonML&#x27;s flagship use-case inside Facebook. If so, it will be interesting to know what impact this has on its development.
评论 #22473011 未加载
评论 #22469836 未加载
WhyNotHugo大约 5 年前
I don&#x27;t know anyone who uses Messenger, yet, I&#x27;ve heard of people moving to specific countries where it&#x27;s the de facto and you can&#x27;t have a social life without it.<p>I&#x27;m also aware of how iMessages and SMS are used in the US, yet this is very US-specific, and I don&#x27;t believe any other country uses SMS.<p>For Chinese people, WeChat is the standard, and what pretty much anyone uses.<p>In Argentina and the Netherlands (and I believe much of the EU), WhatsApp is ubiquitous.<p>Yet, I don&#x27;t know a single person who uses either SMS or Messenger, or iMessages.<p>So what truly fascinates me, is how different companies put so much work into developing such sophisticated messaging apps, but they&#x27;re all reinventing the wheel and each consumed in different regions -- I think nobody would have guesses years ago that we&#x27;d have so many different apps used in different countries, and not at all inter-operating with each other.
评论 #22469841 未加载
评论 #22472839 未加载
评论 #22470565 未加载
评论 #22469840 未加载
jconley大约 5 年前
This is an interesting business decision. To rewrite such a large app must have cost a fortune. Going full native is probably going to increase the cost of future development as well. Aside from the costs of writing&#x2F;maintaining the code, pushing more work to the servers is an ongoing cost. Realtime, always-connected, apps are costly to run even when you push the majority of the state management to the client and just route packets around. They must really want eyeballs in their messenger app! There must be some future plans for this app that warranted such a major effort. Taking on Tik-Tok, perhaps?
评论 #22468687 未加载
benbristow大约 5 年前
Just downloaded the latest update on my iPhone XR. Does seem a lot more snappy and I&#x27;m loving the recent UI&#x2F;UX changes too, especially the sending photos &amp; GIF changes.<p>Good work Facebook!
gigatexal大约 5 年前
SQLite does it again! I love that they&#x27;re using it for internal state management of the UI
stuaxo大约 5 年前
It&#x27;s hard to be excited about anything FB do, when we know how poisonous it is.
ska大约 5 年前
Not sure how much impact this will have, most of the people I know and have discussed this with fall into two camps: people who use FB a lot an will put up with a bad mobile client, and people who don&#x27;t want FB on their phone, ever.<p>I have to go years back to think of someone who told me they just couldn&#x27;t take the bad UX of the clients so they deleted it.
评论 #22468136 未加载
评论 #22469477 未加载
评论 #22469813 未加载
评论 #22469159 未加载
Doctor_Fegg大约 5 年前
Here&#x27;s a way in which they can save 100% of the size: Stop stubbornly barring mobile clients from using the web interface. This is why I don&#x27;t use Facebook Messenger at all.
评论 #22468038 未加载
评论 #22468102 未加载
评论 #22468030 未加载
评论 #22468001 未加载
BooneJS大约 5 年前
Sounds neat, but I’ll continue to use “request desktop website” on mobile safari in a vain attempt to prevent running whatever else this app does besides chat.
jandrese大约 5 年前
This seems like an incredibly low bar to hurdle. FB Messenger on iOS is legendarily bloated. In the couple of weeks I had it installed it also managed to be the biggest battery drain on my phone, even more than some 3D games.
评论 #22467993 未加载
评论 #22468110 未加载
throw03172019大约 5 年前
Does having 40 contact screen designs seem normal?
cjamesd大约 5 年前
This is a bit cynical (and borderline paranoid) but what if the reason for the rewrite was to remove privacy-violating code that was becoming a greater and greater liability? Also, wonder if they needed to do this to make way for end-to-end encryption we&#x27;ve been hearing about?
listsfrin大约 5 年前
Too little and too late. I feel like they lost a whole generation of people.
评论 #22468668 未加载
评论 #22469048 未加载
solarkraft大约 5 年前
To me a lot of the new architecture just seems obvious (don&#x27;t keep the same view 40 times, don&#x27;t invent your custom app specific everything ...) and I really wonder how the original project could derail that far. Too many resources? Institutional bloat?<p>That said I find it a bit heart warming that all the major apps are now between 1&#x2F;2 and 1&#x2F;4 the size of what they were just a few years ago. I didn&#x27;t expect the tech companies to ever realize the problem with insane sizes. Is a similar debloating happening to Electron apps?
tim--大约 5 年前
I wonder what this means for older versions of Messenger? Facebook talks about rewriting their server logic to support all the removed code from the mobile interface, but does this mean that we will soon see support for &lt; iOS 10 (which Messenger does not support for new versions, as far as I ma aware) be dropped?<p>It&#x27;s pretty sad that a Messaging app can&#x27;t be run on a perfectly fine nine year old device. Bring back IRC :)
1023bytes大约 5 年前
So it&#x27;s basically MVVM with SQLite as the model?
adam_fallon_大约 5 年前
I feel like I had an aneurysm reading this. For 6 paragraphs the repeat that they shrunk the lines of code down, that the rewrote the whole thing and that it’s a massive undertaking and that a message app should be small. 6 paragraphs of that slightly reworded and I just gave up. I honestly think this was written by a bot.
评论 #22470774 未加载
ckdarby大约 5 年前
It&#x27;ll suck for the SEO team at LightSpeed point of sale company.<p>FB named a open source project the same name as a company.
评论 #22468626 未加载
评论 #22472303 未加载
评论 #22469503 未加载
评论 #22469418 未加载
jpeeler大约 5 年前
Wish they had gone into more details about the budgets. Unless a project is bug fix only for life, how can one set a binary size or lines of code upper limit? I&#x27;ve heard that the best developers delete more than they write, but in practice I don&#x27;t think that happens very often.
thekid314大约 5 年前
Security isn&#x27;t mentioned once.<p>I really wonder if in their meetings they sold the speed and lighter weight as a bonus for the user or for the collection of data on the user. This must reduce their overhead and be kinder on their servers.
Thorentis大约 5 年前
I still aren&#x27;t 100% sure what they&#x27;re using Sqlite for? Are they storing templates as blobs? Are the storing template logic in the table? How did that make things faster? Anybody who has more detail care to explain?
评论 #22469476 未加载
beefield大约 5 年前
Assuming one hates notifications, is there _any_ reason why anyone would want to use app over m(basic[1]).facebook.com?<p>[1] to access messenger because fb stubbornly thinks I want to install their crap&#x2F;spyware on my phone
评论 #22468410 未加载
评论 #22468281 未加载
llovan大约 5 年前
RIP React Native
评论 #22472282 未加载
评论 #22471030 未加载
chendragon大约 5 年前
Now if only they would rewrite the web application too, or release that desktop app they were talking about last year. The web app is much, much slower than the phone app.
manigandham大约 5 年前
Facebook&#x27;s video player experience is absolutely terrible.
z3t4大约 5 年前
Once you are several years into a software project, everything feels like a weekend project, you somehow lost all sense of time-cost&#x2F;benefit...
jbverschoor大约 5 年前
Thank you! Eventhough I&#x27;ve removed Messenger from my habits, I checked it out, and it&#x27;s really snappy and super fast with starting up.
moron4hire大约 5 年前
Do they still block use of the web UI for Messenger in mobile browsers, unless I check &quot;show Desktop version&quot; in my browser settings?
dlsso大约 5 年前
They said they reduced code 84% but the numbers they gave are a 79% reduction. If they&#x27;re using different metrics they should explain.
_bxg1大约 5 年前
Was the previous one React Native? Seeing the talk about UI abstraction layers and given that this is Facebook
anant90大约 5 年前
&gt; And yet, for the people using the app, it won’t look or feel much different.<p>Yikes. Okay, I know I&#x27;m maybe being a bit unfair here, but I&#x27;m sorry to say that this is one of the weakest engineering blog posts I&#x27;ve ever read. This seems to be a massive &quot;let&#x27;s end the craziness and finally pay our tech debt&quot; effort. Good for them, but not something that excites me about working at Facebook.
评论 #22471921 未加载
eyegor大约 5 年前
I&#x27;m truly shocked how many resources are dedicated to maintaining a chat app that essentially just talks to an api. Seems like you could easily build and maintain a simple chat system with &lt;5 developers. You wouldn&#x27;t have shiny new features, but it would by coincidence be faster and simpler. Networked chat is a standard project in university.
评论 #22470642 未加载
评论 #22471697 未加载
chj大约 5 年前
&gt;from more than 1.7M lines to 360,000.<p>At first look, I thought it is 36k, that would be truly great.
tiffanyh大约 5 年前
Does anyone know if FB dropped Messengers C code for WhatsApp Erlang based code?
_bxg1大约 5 年前
I&#x27;d be curious to see more details on how pub&#x2F;sub works with SQLLite
cbhl大约 5 年前
It looks like polls aren&#x27;t yet implemented in the rewrite?
noncoml大约 5 年前
Project lightspeed required 23.94 MB &#x2F; 11.83 MB to download the webpage and made the browser crawl on a i7 32Gb PC. Oh the irony..
trustfundbaby大约 5 年前
So ... no more React? what did they use? swift?
SkyMarshal大约 5 年前
The technical meat of this post is below. It looks like they mostly eliminated functionality in their app code wherever it was redundant with either OS functionality, SQL Lite capabilities, or the Messenger backend servers at Facebook&#x27;s datacenters.<p><i>&gt;One of our main goals was to minimize code complexity and eliminate redundancies. ... To build this unified architecture, we established four principles: Use the OS, reuse the UI, leverage the SQLite database, and push to the server.</i><p><i>&gt;We accomplished this by using the native OS wherever possible, reusing the UI with dynamic templates powered by SQLite, using SQLite as a universal system, and building a server broker to operate as a universal gateway between Messenger and its server features.</i><p><i>&gt;... the existing OS often does much of what’s needed. Actions like rendering, transcoding, threading, and logging [and JSON processing] can all be handled by the OS.</i><p><i>&gt;To simplify and remove redundancies, we constrained the design to force the reuse of the same [UI] structure for different [UI] views. So we needed only a few categories of basic [UI] views, and those could be driven by different SQLite tables.</i><p><i>&gt;Now, ... All the caching, filtering, transactions, and queries are all done in SQLite. The UI merely reflects the tables in the database.</i><p><i>&gt;We developed a single integrated schema for all features. We extended SQLite with the capability of stored procedures, allowing Messenger feature developers to write portable, database-oriented business logic, and finally, we built a platform (MSYS) to orchestrate all access to the database, including queued changes, deferred or retriable tasks, and for data sync support.</i><p><i>&gt;MSYS is a cross-platform library built in C that operates all the primitives we need. ... With MSYS, we have a global view. We’re able to prioritize workloads. Say the task to load your message list should be a higher priority than the task to update whether somebody read a message in a thread from a few days ago; we can move the priority task up in the queue.</i><p><i>&gt;With MSYS, it’s easier to track performance, spot regressions, and fix bugs across all these features at once. In addition, we made this important part of the system exceptionally robust by investing in automated tests, resulting in a (very rare in the industry) 100 percent line code coverage of MSYS logic.</i><p><i>&gt;For anything that doesn’t fit into one of the categories above, we push it to the server instead. We had to build new server infrastructure to support the presence of MSYS’s single integrated data and sync layer on the client.</i><p><i>&gt;Coordinating logic between client and server is very complex and can be error-prone — even more so as the number of features grows. ... </i><p><i>&gt;Similar to MSYS on the client, we built a server broker to support all these scenarios while the actual server back-end infrastructure supports the features.</i><p><i>&gt;[To minimize code-base growth] We also built a system that allows us to understand how much binary weight each feature is bringing in. We hold engineers accountable for hitting their budgets as part of feature acceptance criteria. Completing features on time is important, but hitting quality targets (including but not limited to binary size budgets) is even more important.</i>
djsumdog大约 5 年前
I wonder if this will break libpurple-facebook or the Matrix-facebook-bridge
chadlavi大约 5 年前
tracking you everywhere you go is easier than ever!
buboard大约 5 年前
how does one manage to make a <i>chat</i> app bloated in 2020?
评论 #22468232 未加载
Priem19大约 5 年前
A great way to speed up the pace to their next scandal. <a href="https:&#x2F;&#x2F;www.quitfacebook.org" rel="nofollow">https:&#x2F;&#x2F;www.quitfacebook.org</a>
miki123211大约 5 年前
Am I the only one who thinks 86mb for an app is about 86 times too much?<p>Windows Messenger was about 900k. Sure, it only did text, but Skype wasn&#x27;t that big either. I&#x27;d accept 20mb for stickers, givs and stuff but 80? And 300k lines of code? For a messaging app? It just seems... unreasonable to me.
评论 #22470085 未加载