7 ms·
Redex: an Android bytecode optimizer developed by Facebook
- yincrash 10y agoDebugging a crash report from an app with both proguard and redex sounds like it would be a nightmare.
- AstralStorm 10y agoBoth Proguard and ReDex can be coaxed to unmangle names (produces a special file and has a tool to decode mangled traces) They don't really do any major optimizations - they're not a real SSA/CSE/eta-form optimizer, like what llvm does to its bytecode.
- tananaev 10y agoOn my Nexus 4 facebook app takes ages (a few minutes) to update/install. I wonder if Redex "optimization" is the reason for that.
- mckilljoy 10y agoRedex runs at compile time, not at install time.
- tananaev 10y agoYes, but it changes the byte code, and I think android compiles that code into machine code when you install an app.
- muricula 10y agoIf anything it sounds like it would be faster because there is less byte code which needs to be compiled. Most likely the problem is the Facebook app has a lot of bytecode. That's probably why the wrote redex in the first place, so they would have less bytecode in their final APK.
- tananaev 10y agoAny other app takes seconds to install. Facebook takes minutes. I can understand some difference, but not that much.
- Lx1oG-AWb6h_ZG0 10y agoTheir ios app has over 18000 classes (https://www.reddit.com/r/programming/comments/3h52yk/someone_discovered_that_the_facebook_ios/ https://www.reddit.com/r/programming/comments/3h52yk/someone...), so I can easily believe the android app is similarly bloated as well. (To be fair, most of the 18K classes seem to be auto generated, but that still doesn't lessen the compiler's burden.)
- spacemanmatt 10y agoI heard there are something like 400 mobile developers working on the FB apps. I don't know there's any way to keep a team that size from producing bloat with every revision.
- iainmerrick 10y agoThat seems like a useful engineering problem for Facebook to try to solve, rather than this bullshit rocket science optimization stuff that adds yet more complexity for only incremental gains.
- pcwalton 10y agoCompiler optimizations are not "bullshit rocket science optimization". You depend on them every day. None of the optimizations in this tool are "rocket science" compared to the optimizations that GCC, for example, does.
- iainmerrick 10y agoRight, so on Android if you need code to be fast, write it in C++. If you have a ridiculously bloated and buggy Java app, writing an optimizing compiler doesn't sound like the most effective solution.
- timdorr 10y agoThat is actually going away in Android N: http://developer.android.com/preview/api-overview.html#quick_path_to_app_install http://developer.android.com/preview/api-overview.html#quick...
- nickmain 10y agoUnfortunate name collision: https://redex.racket-lang.org https://redex.racket-lang.org
- ori_b 10y agoIt's also a well known term in programming language theory: https://www.classes.cs.uchicago.edu/archive/2002/winter/CS33600/slides/Lesson2.pdf https://www.classes.cs.uchicago.edu/archive/2002/winter/CS33...
- takno 10y agoIt's honestly pretty difficult to believe that any kind of optimization has taken place on the Facebook app. I don't have the time or the bandwidth to keep up with the updates
- Ambroos 10y agoIt is indeed out of control. They have so much stuff in their app that an update takes over 2 minutes to run on Marshmallow on a total high-end device (Snapdragon 810). No other app comes even close to taking that long to precompile for ART. Which is surprising really, considering their Messenger app is excellent, fast and lean.
- smrtinsert 10y agoStopped using it and never looked back (as they say). Battery life much improved and more time for other more productive social mediums.
- piyush_soni 10y agoI uninstalled it as well, and noticed that the mobile website for facebook is much better in performance than the so called 'native' app.
- mwcampbell 10y agoHow does this compare to ProGuard?
- bertr4nd 10y agoIt's conceptually similar, but we've focused on optimizations that add value on top of ProGuard - we do use ProGuard internally, so the improvements we're seeing from ReDex are on top of that. We get a lot of leverage out of operating on dex directly, as the final step in the build. For instance we can make really good inlining decisions because we know how many virtual registers the caller and callee use.
- amolgupta 10y agoDo I need to care about any more configurations when using it along with proguard? Like extra lines in proguard.txt or change of mapping files when uploading to my crash reporting tools?
- bertr4nd 10y agoYou shouldn't need to change your proguard config to use redex. For mapping files, the one thing that can trip people up is that we strip out source file names. After you run redex there should be a /tmp/filename_mappings.txt to do the back-mapping, similar to proguard. If you're using third-party crash reporting tools that don't understand that back-map, though, you can always turn off the source stripping. We describe how to do that here: https://github.com/facebook/redex/blob/master/docs/Config.md https://github.com/facebook/redex/blob/master/docs/Config.md.
- bertr4nd 10y agoHey all, ReDex developer here, happy to answer questions!
- edderly 10y agoThanks for sharing, do you still see runtime performance benefits when ART is used or just compilation / dex2oat perf improvement?
- cloudjacker 10y agoDoes Jack and Jill fuck your shit up?
- bertr4nd 10y agoLol. Actually I'm pretty interested to see what we can do with jack, since it has an API to hook into various stages of the code generation pipeline. We haven't invested much time in it yet though, since it's still in a somewhat experimental phase. Looking forward to investigating it more, though.
- jevinskie 10y agoHow are you handling the Gradle experimental plugin and Jack/Jill (no problems because you operate at dex level?)? I heard Proguard and other class/dex transformations were having trouble adopting the new model. Supposedly Google is working on adding extension points to the API.
- wnevets 10y agoI am assuming the facebook app doesn't use this?
- bertr4nd 10y agoYes, of course we do! It's the motivating example for ReDex :-)
- Yhippa 10y agoI think you missed the joke.
- bertr4nd 10y agoMy next invention will be a sarcasm detector.
- fit2rule 10y agoMaybe you could stop inventing things and .. you know .. make your software better for the end user. The Facebook app is one of the most hated apps in my household, and we've all stopped using it.
- pestaa 10y agoGoodness, give him a break. It's not like they aren't trying to do something about it.
- andrewingram 10y agoYes, it's a well-known fact that everyone contributing to a piece of software is working on the same problem and that multiple problems can't be worked on in parallel.
- fit2rule 10y agoHe is working on the very problem we need him to work on. I'm telling him to get back to work and stop dorking around on HN, because there is tons, and tons, more work to do - and I fail to see how HN is anything but a distraction for someone working on this issue.
- donnfelker 10y agoI'm happy that FB is releasing these tools. I really am, but you know what I want? I want to use the FB app with out it DESTROYING my phone's usability. Anytime FB is installed on any of my devices, the device degrades day after day until the phone is virtually unusable. Next step: Uninstall Facebook. Phone is usable again. I only use Nexus devices with a lot of space on them, so ... it's not like I'm using a cheap burner. Unfortunately, due to this problem, I've been using the FB mobile website for a very long time. Every 3-6 months I'll re-install the FB Android app in hopes that things are better, only to be let down once again. Something tells me that all this bit flipping that FB is doing is not making things better, but worse. Sure, it may be better for the FB app, but worse for the device general. This is just my speculation at this point though ...
- incepted 10y agoAgreed. I think the Facebook engineers have a tendency to fix symptoms rather than causes. A lot of their engineering creations are trying to shrink the binary while they might want to consider revisiting all the dependencies that their application depends on, because that graph (and the size of their apk) is really absurdly large for such an app. Of course, there's also the fact that such a tool is already partially obsolete because of Jack and Jill.
- voltagex_ 10y agoI've actually got to sit down and debug my Nexus 5. I don't run the FB app but it's degrading in the same kind of way. No real easy cause that I can see. I'm hoping adb can shed some light for me.
- therealmarv 10y agoI'm guessing it has so much old "legacy" code long before all this new cool inventions like React Native etc. were invented. I wonder why they cannot start from scratch a new one which has a better architecture and does not slow down your phone.
- goda90 10y agoI've never been comfortable with the FB app phoning home so I too use the mobile website. The thing about it is that the text fields don't work well at all. Slow response times, no way to go back and correct my errors without erasing everything, and repetition of words. Over the years and across browsers the issues change but they've never worked like most other text fields on mobile websites. I wish I knew what they were doing to make them behave so poorly.
- yinghau76 10y agoHow can I integrate Redex with gradle building?
- haidrali 10y agohow many developers ( companies ) other then Facebook already using Redex or any of these kinds of optimisations ?
- yongjhih 10y agoredex as a docker container: https://github.com/yongjhih/docker-redex https://github.com/yongjhih/docker-redex