Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Android Open Source Software News

The Android Lag Fix That Really Wasn't 226

jfruh writes "When Android was first introduced, it got much of its buzz in the open source community, and despite it being a mobile juggernaut backed by huge companies, it remains an open source project that anyone can submit code to. Thus, when a community patch that claimed to reduce the lag that still plagues the platform was created, it rocketed around various community code sites and was widely praised. The only problem: it didn't actually speed Android up."
This discussion has been archived. No new comments can be posted.

The Android Lag Fix That Really Wasn't

Comments Filter:
  • If the problem is that they can't generate "random" number fast enough, maybe they could just return 42 when the entropy pool is empty.
  • by toygeek ( 473120 ) on Saturday January 12, 2013 @11:44AM (#42567953) Journal

    This is why "vortex" generators for carburetors are still sold http://www.vorteccyclone.com/ [vorteccyclone.com] , Magnets for your fuel lines to "align the molecules" http://en.wikipedia.org/wiki/Fuel_saving_device [wikipedia.org] are still sold, and oddly shaped bicycle cranks http://z-torque.com/ [z-torque.com] are still sold. Its really no surprise that it happens in the software world too. Really, its been happening for a long time. Regcure, anyone?

    • by fuzzyfuzzyfungus ( 1223518 ) on Saturday January 12, 2013 @12:09PM (#42568115) Journal

      The surprising thing, in both this Android case and the assorted car-widgets, is not that the placebo effect works; but that the "If it was that easy, why didn't it come from the factory that way" argument hasn't held more sway.

      In the case of the 'vortex' device you link to, the argument is essentially that ~$1 worth of stamped metal could markedly improve the performance and fuel economy of most vehicles without other notable modifications. Short of a full-scale Petroleum-industrial-complex coverup, why aren't these things being bolted on at the factory?

      In the Android case, it's not like entropy related issues are news to linux users or hardware makers. Devices that do lots of crypto(ie. network gear designed to support a lot of VPN users, http load balancers designed to serve a lot of SSL sessions, etc.) are frequently provided with dedicated hardware RNGs precisely to prevent performance issues on entropy depletion. VIA's more recent CPUs come with an on-die hardware RNG, and you can buy assorted RNGs for various expansion busses if your applications require it.

      The issue isn't so much that you can entropy-starve a system and cause it to respond badly; but that(against a background of people already knowing that) Google went and released an OS that is somehow radically more demanding on /dev/random than most linux variants and didn't even notice? That would be a bit of a surprise.

      • In the case of the 'vortex' device you link to, the argument is essentially that ~$1 worth of stamped metal could markedly improve the performance and fuel economy of most vehicles without other notable modifications. Short of a full-scale Petroleum-industrial-complex coverup, why aren't these things being bolted on at the factory?

        Because Company/Lobby X paid them $$$ NOT to include thingamajig that would save you money by not buying the product X or by buying less of it - making less money for the Company X.

        It's all a part of the plan. [wikipedia.org]

      • by tlhIngan ( 30335 )

        In the Android case, it's not like entropy related issues are news to linux users or hardware makers. Devices that do lots of crypto(ie. network gear designed to support a lot of VPN users, http load balancers designed to serve a lot of SSL sessions, etc.) are frequently provided with dedicated hardware RNGs precisely to prevent performance issues on entropy depletion. VIA's more recent CPUs come with an on-die hardware RNG, and you can buy assorted RNGs for various expansion busses if your applications req

  • by Anonymous Coward on Saturday January 12, 2013 @11:45AM (#42567959)

    but sent using Android, so...

  • by darkHanzz ( 2579493 ) on Saturday January 12, 2013 @11:46AM (#42567969) Journal
    The butter project was about latency with user interaction. The issues talks about /dev/random, which is totally unrelated.
    • by sribe ( 304414 )

      The butter project was about latency with user interaction. The issues talks about /dev/random, which is totally unrelated.

      Well, you'd hope it was unrelated, but sometimes I'm no so sure ;-)

    • by hey ( 83763 )

      Look at the first sentence of the linked page: The Linux entropy pool is frequently empty as Dalvik appears to always use /dev/random, which depletes the entropy pool and will block when the pool is empty. This blocking results in user perceived poor performance.

      • I was under the impression that the fix did actually speed it up, but at the cost of battery life. You could have got effectively the same performance enhancement by changing the process scheduler to 'performance' rather than 'on demand'. As someone with an older phone running Cyanogen, I was hoping this fixed helped. My performance problems tend to be more memory related though as the older phones are quite short on RAM.

        • Which "fix"? There have been many proposed. The only ones with a measurable effect have been ones which caused battery issues. What these did were renew the entropy pool quite frequently and as a result the CPU never went to sleep. The effect it had was changing the CPU governor to always keep the device awake. No wonder that improved performance.

          This entire debatable has been nothing but one great placebo, and really at this point I think it actually reflects quite poorly on the XDA community who are full

      • Look at the first sentence of the linked page: The Linux entropy pool is frequently empty as Dalvik appears to always use /dev/random, which depletes the entropy pool and will block when the pool is empty. This blocking results in user perceived poor performance.

        The problem is that XDA-Developers seem to have attracted a lot of script kiddies who've done Java / C / Programming 101 and think that they know everything. Despite endless threads about this Google's own developers have come out said that Dalvik does not use /dev/random for anything.

        Better still none of the proposed fixes had any measurable improvement in performance except for one which quickly drained the battery (and likely kept the CPU awake at all times and running at full speed).

    • by n30na ( 1525807 )
      The original fix in question was feeding /dev/urandom into /dev/random because the entropy pool was running low and sometimes running out, which is what was causing ui hitching.

      Of course, it was actually just an old android bug that'd been fixed ages ago, iirc.
  • Apparently, the placebo effect also works to cure percieved computer ailments...

    • by nomel ( 244635 )

      I don't get it. There were no numbers posted in the thread. This doesn't mean placebo, this just means there are no numbers posted. The claim that it's placebo has just as much foundation that it's not. Write a benchmark and test it, you could get exactly 2 minutes of fame.

  • by Freggy ( 825249 ) on Saturday January 12, 2013 @12:09PM (#42568117)
    The problem is that xda is full of this kind of crap. Kernels which disable fsync (libEAT-MY-DATA, anyone?), exotic I/O schedulers and CPU governors, overclocking processors and other hacks... Very often, they do not have any measurable effect, or even cause new problems, such as freezes, hangs, sleep of death,...
    • by AdamWill ( 604569 ) on Saturday January 12, 2013 @12:31PM (#42568285) Homepage

      yep, the place is cargo cult central. stick with builds of the major ROMs from affiliated devs, is my advice. Run like hell from the threads which are kangs of those builds with some kid's AWESOME BLACK THEME and a bunch of kernel patches he picked up somewhere.

      • Re: (Score:3, Insightful)

        by Anonymous Coward

        The funny thing is those dweebs spill out onto the general internet and tell everyone they need to hack their phones.

        Then you read a 45 page thread only to find that their wicked sweet ROMz don't support the camera and give the phone 30 minutes battery life. Gee thanks, Melvin.

  • by godrik ( 1287354 ) on Saturday January 12, 2013 @12:38PM (#42568339)

    There are a lot of comments on the bug report page. Clearly this is not a dalvik bug since dalvik does not use the /dev/random. But the other commentatros are still unsure that there might not be some issue in how randomness is generated in android from user input, which might induce lag.
    Right now, some folks still investigate.

  • Well yeah... (Score:2, Insightful)

    by kiriath ( 2670145 )

    Because you can't fix stupid.

  • >> "didn't actually speed Android up."

    If you actually read the bug mentioned in the summary - most devs are arguing that explanations about why the fixes work don't make sense in terms of Dalvik (java) that the android bug was filed against - not that it doesn't improve latency or that it doesn't work or there isn't a lower level issue. One developer https://code.google.com/p/android/issues/detail?id=42265#c162 [google.com] (sorry I don't know enough about android to know if he is part of the core team or not)

  • This looks like a real bug to me.
    The problem is that many apps use /dev/random instead of /dev/urandom, which of course causes them to be unnecessarily slow.

    A "hack" was to make /dev/random behave like /dev/urandom, but it's not clean, which is why it's not done in the official version.

  • by DeathToBill ( 601486 ) on Saturday January 12, 2013 @01:15PM (#42568611) Journal

    Having slogged through the linked discussion, there is no conclusion either way whether this effect is real or not. There are several theories on mechanisms that could cause an increase in responsiveness, but no conclusion. The most plausible seems to be that when the entropy pool is near empty, each input event causes a context switch as it is used to refill the entropy pool. Slower input handling obviously leads to poor responsiveness.

    The summary seems to just be random android-bashing.

  • by Luthair ( 847766 ) on Saturday January 12, 2013 @01:30PM (#42568711)

    Reading that bug report makes me incredibly glad that I've only worked on open source developer tools, if the comments on that bug report are typical I imagine Google must have high turn-over of developers on the project.

  • by buser ( 2545806 ) on Saturday January 12, 2013 @02:13PM (#42569021)
    Apparently the OP didn't read the thread he alleges disproves the performance increase. There is actually a very lively discussion going on about it, and while there's a general agreement that it's not as simple as the /dev/random pool getting depleted, there is some evidence that it is related to locking in the UI (see comment 162).
    • Re: (Score:2, Flamebait)

      by Flipao ( 903929 )
      The OP is simply yet another MS shill trying to spread the usual FUD.

      Speaking from personal experience I own an Ipad 2 and a Nexus 4, the UI in the iPad 2 is smooth as silk as usual, the UI in the Nexus 4 is even better in terms of speed and responsiveness. Switching between applications is seamless and the UI will not drop a single frame.

      The user experience in Android was lacking until Matias Duarte took over the UI, in modern phones it's as good if not better than anything on the market, period.
  • by Miamicanes ( 730264 ) on Saturday January 12, 2013 @03:14PM (#42569493)

    There are basically four things that make Android laggy. The good news is that most of them can be overcome by user-modified firmware. The bad news is that manufacturers and Google are unlikely to ever fix them directly, because it would increase the manufacturing cost of phones by a few cents.

    ONE: KILL-VS-SWAP

    Android's normal behaviour is to aggressively kill activities and suspended background tasks, then respawn them from scratch when brought back into the foreground or reactivated. The LINUX (and Windows) norm is to simply quit giving them CPU cycles, stash their state into swap space on the hard drive, and resurrect them later.

    One reason why this is done is because Android devices, while not necessarily STARVING for flash, don't have it in quite the abundance that a normal computer has hard drive space. There are also concerns about prematurely wearing out flash. The problem is that flash rewrite life estimates are based upon general use of the entire block of memory... but a swap partition gets created in a specific chunk of flash, and that one tiny chunk gets relentlessly hammered. If your erase-rewrite activity gets spread across the whole flash, it would usually take months of active efforts to be destructive before you really caused damage. However, if you create a 256mb swap partition and hammer it relentlessly, you can permanently damage it in a weekend. For this reason, few at XDA will advocate ever using internal flash for swap.

    That brings up catch #2... if you swap to microSD (because it's cheaply replaceable should you end up damaging it), you really need class 6 or better. Swapping to class 2 flash will leave you running more slowly than if you left Android to its default behavior. Guess what class of flash invariably comes with the free microSD card shipped with the phone? Class 2.

    Making matters worse, the users in the best position to experiment with swap enhancements are Nexus owners. Unfortunately, Google has this near-religious aversion to microSD, and I don't think any Nexus device since the original Nexus One has shipped with a microSD slot. All that said, if you have a rooted and reflashed Android phone with class 6-10 microSD that has a swap partition and a custom ROM that uses it, you MIGHT see a big reduction in lag if you frequently run apps that have "expensive" startup costs (ie, apps that always begin by trying to make a http request to somewhere, or generate cryptographically-secure random numbers, etc).

    TWO: DISDAIN FOR 2D GPU ACCELERATION

    Historically, Android hasn't done a good job of putting 2D acceleration to good use ICS was a step forward, but you can't help but feel like the GPU support is more symbolic, half-assed, and buried under 400 abstraction layers that fritter away most of its potential. At least, for simple and straightforward "scroll and/or pan the viewport across a large virtual bitmap" type operations.

    Compounding the problem is Android's architectural bias towards generating content on the fly, instead of generating humongous virtual bitmaps and keeping them available for instant viewport rendering.

    THREE: ANDROID'S MEMORY-MANAGEMENT SUCKS

    Building upon 2, and being completely blunt... Dalvik's memory-management totally fucking sucks compared to Java's. ESPECIALLY the way it handles short-lived objects that get repeatedly created in large numbers, and discarded almost immediately.

    I dare anyone to disagree. Half the Android API bends over backwards to tiptoe around Android's shitty heap-management by trying to avoid creating and discarding objects for use as short-lived containers.

    No, don't give me crap about mobile devices having limited resources compared to desktop computers. That's bullshit, and everyone knows it. Java mostly solved the worst of its memory-management problems around 1.5. Compare the specs of a high-end laptop circa ~2002 with the specs of a Galaxy S3, and arguments about Android devices being "severely resource limited" just kind of fall on the ground and thrash aroun

    • by Solandri ( 704621 ) on Saturday January 12, 2013 @05:03PM (#42570153)

      That brings up catch #2... if you swap to microSD (because it's cheaply replaceable should you end up damaging it), you really need class 6 or better. Swapping to class 2 flash will leave you running more slowly than if you left Android to its default behavior. Guess what class of flash invariably comes with the free microSD card shipped with the phone? Class 2.

      This is a common misconception. The class of the SD card is a rating for sequential write speed, nothing more. It's important for cameras and camcorders - in fact it was developed for camcorders because some memory cards simply couldn't write the video data as quickly as the device was sending it to the card.

      For an Android device you're more interested in its 4k random read/write performance. It's basically a computer reading/writing lots of small files, so it'll be most impacted by 4k read/write speeds.

      As it turns out, manufacturers can tune a flash card for a certain type of performance. If you tune it for faster sequential speeds, random speeds suffer. Likewise if you tune it for random speed, sequential speeds suffer. The class 10 cards I've benchmarked typically hit 10-20 MB/s on sequential writes, but will bog down to as slow as 0.004 MB/s on random writes (yes, 4 kB/s - it was the card I bought before I learned all this. It took 4 hours to copy 4 GB of sheet music and MP3s to that class 10 card - a blissful 0.28 MB/s). Here are the CrystalDiskMark scores I got for a 32 GB class 4 card I have:

      seq: 22.9 MB/s read, 4.3 MB/s write
      512k: 22.0 MB/s read, 1.3 MB/s write
      4k: 3.3 MB/s read, 1.3 MB/s write

      Yikes! Only 4.3 MB/s write speed. Who would ever want that? Well look at the benchmarks for a 16 GB class 10 card I have:

      seq: 21.8 MB/s read, 12.0 MB/s write
      512k: 21.5 MB/s read, 0.9 MB/s write
      4k: 5.7 MB/s read, 0.008 MB/s write (not a typo)

      So yeah it's 3x faster at sequential writes. But it's slower at 512k writes, and more than 160x slower at 4k writes. It's definitely a very bad choice for an Android device despite being class 10.

      The sweet spot for Android is around class 4 or 6. That gets you good 4k write speeds without punishingly poor sequential write speeds (which are important if you're doing something like copying a movie to the card). That said, not all cards are created equal. The "class 2" Samsung card which came with my phone is hands down the best card I've tested overall. It peaked at 11 MB/s sequential writes (meaning it could've been rated class 10), while 4k random writes were still above 1 MB/s. Sandisk is another company which seems to underrate their cards (and their class 10 cards have better if not stellar 4k random write speeds), which is why they're usually highly recommended for Android devices.

      tl;dr - You want a class 4 or 6 card, or a good class 2 card for your Android device. Not a class 10 card.

      • by gTsiros ( 205624 )

        you reach a concluding advice while ignoring the very thing you yourself said: class is for seq writes.

        which means that if you write many small things in your card, you need a class 4. However, what if you need your card to write large files?

        of my 32GB card in my arc, 28GB are FLAC and the rest is mostly empty (perhaps 10 photographs at most, far *far* less than even 1GB)

        so your idea of using a class 4 (which i did, the 32GB it came with was class 4) would be torture for me when i update its library.

        think a

    • by kryps ( 321347 )

      There are lots of other issues. Two examples:

      A) The Dalvik JIT is stone-age technology compared to modern JITs. We are not even talking about profile-guided optimization like the HotSpot VM does. No, it does not even inline getters or setters,

      B) The GPU acceleration layer sucks even worse than you think. For example it requires the app to emit display lists for all graphical objects without allowing you to clip those objects first. That means if you have a huge number of objects (say an editor with thousand

    • So when I click to dial someone on my DroidX, and I can fast count to 20 before the phone connection screen even launches, which of the four problems above do you think it is? I'll experiment with your solutions (does CyanogenMod help?), but I'm curious what you think the main culprit is with something as simple as calling - or worse, answering - using the default phone app.

    • by fa2k ( 881632 )

      FOUR: ANDROID'S DEFAULT CPU GOVERNORS MAKE AN ANNOYING PROBLEM INTOLERABLE

      This is very interesting, as almost all desktop computers use ondemand too. My old CPU was a Phenom II quad core at 3400 MHz and it was noticeably slower on "ondemand" for interactive stuff. I ended up writing a script to pin it at performance, and switch to ondemand when the screen saver was on. Now I'm using a Xeon and I haven't noticed any difference. The Xeon only clocks down to 1600 MHz, while the AMD went all the way down to 800 MHz.

      I wonder why the "interactive" governor isn't available on my desktop

  • I have a G2. Not rooted or anything. Most of the time it's fine. Every so often, when I touch keypad buttons during a call, Nothiing Happens. A few seconds later, any and all buttons I've hit will play back very very fast.

    It really is quite noticeable.

  • Have not seen this problem, but I have a problem with external mouse not scrolling. It's a registered bug in the database, closed, with a patch - but I have no idea what that means or when/if Samsung will roll that out - ha!

What hath Bob wrought?

Working...