Author Topic: Performance tuning L34C thru added Swap Space and tweaking swappiness  (Read 3468 times)

0 Members and 1 Guest are viewing this topic.

  • Thank You
  • -Given: 0
  • -Receive: 1
  • morbius

    Posts: 38
    User Rating: +4/-0
    • *
    • Jr. Member
    So I benchmarked the effects of an added swap partition on my L34C, mounted on the external SD card, a 16gb Class 4 SanDisk.  Using Antutu's benchmarking app, I tested from a swappiness setting of 0 without any added swap space all the way to a swappiness of 100 and with the added swap space (in the guise of a swap partition) on the external SD card.

    According to AnTuTu's benchmarks -- and granted this might not be the best app for that role, being as it is geared to evaluating gaming performance, and I doubt many would regard a device with a 3.5" screen a good choice for gaming -- in broad strokes, not only is adding swap space nearly a complete waste of effort, you're also better off with less swappiness than with more.

    But before I got to testing the added swap space, I also wanted to optimise external SD card performance, so I benchmarked effects of adjusting the size of its read-ahead cache.  With the default (128kb) setting, according to SD Tools, it scored, on average, 36.1 (Olympic scoring rules).  The best score I got, testing at 256kb increments, was 65.5, which came with the read-ahead setting at a whopping 3584kb.  So my external card reads now are on the order of 80% faster because I upped the cache from 128 to 3584.

    With my external SD card finely-tuned, I turned to the swap area and swappiness.  To cut to the chase, the best overall score came from swappiness set to 20 and with no added swap space.  The combined numeric score of that configuration, according to Antutu, was 9632.

    Swappiness 100 but with added swap space scored 9088.
    Swappiness 100 and no added swap space scored 9213.
    Swappiness 0 but with the added swap space scored 8591.
    Swappiness 0 and no added swap scored 9612.

    I was half expecting this result because I'd come across a tech blogger who claimed Android is very different from 'regular' Linux in the way it handles VM  paging, a difference which results in very, very little data actually being written to disk by the paging process.  Which reduces or altogether eliminates the need for swap space in Android.

    For this reason, I would speculate the outcome of this test is more determined by the nature of Android's paging process, and the relative quality of the L34C's internal SD storage components, than by the "meagre" nature of my Class 4 external SD card.  But I would not be opposed to shelling out for a top-tier SD card if some else got contradictory results from a Class 10 card.

    The only metric in which the high swappiness with added swap space excelled was CPU(multi-thread), both in the 'integer' and the 'floating point' calculations.  Its advantage over second place for 'integer' was only about 5%, but for 'floating point,' it was nearer 20%.

    Based on these results, I gave up my dreams of an added swap file, deleted the swap partition off my external SD card (with remorse) and added startup scripts to /etc/init.d, both to set the external SD card's read-ahead cache to 3584 and to set swappiness to 20 at boot-time.

    The command to set the read-ahead cache (to 3584) is (as SuperUser):
    'echo 3584 > /sys/devices/virtual/bdi/179:0/read_ahead_kb'

    And to display the current setting:
    'cat /sys/devices/virtual/bdi/179:0/read_ahead_kb'

    *Note that your numbered directory (../179:0/. in my example) might be different.

    The command to set swappiness to 20 (again, as SuperUser) is:
    "sysctl -w vm.swappiness=20"

    If the command is effective, it should echo the new setting.  Regardless, you can confirm the current setting with this command:
    'cat /proc/sys/vm/swappiness'

    I note with some amusement that I also have dialed back the swappiness on my Linux Mint desktops from the default value of 60 to a setting of 20, same as the new setting on my L34C, despite the desktops not having the advantage of all these solid state storage devices.

    The OS reads from either setting on the fly, so changes to either take effect immediately, without the need to reboot.

    In any case, the improvement was far from dramatic, particularly in relation to the amount of time I spent on the hacking and the benchmarking to arrive at it.
    • Stock
    • LG Optimus Fuel
    • TWRP
    • Stock-Rooted

    Re: Performance tuning L34C thru added Swap Space and tweaking swappiness

    « Reply #1 on: February 19, 2015, 03:46:58 PM »
  • Thank You
  • -Given: 0
  • -Receive: 0
  • solider on

    Posts: 9
    User Rating: +2/-0
    • *
    • Jr. Member
    Try using a Class 10 (2.5x faster than class 4) microSD or better.

    Class (Denotes minimum sequential read/write speed)
    2 = 2MBs R/W
    4 = 4MBs R/W
    6 = 6MBs R/W
    10 = 10MBs R/W
    U1 = 10MBs R/W
    U3 = 30MBs R/W
    • Custom
    • TWRP
    • Rooted-Rom