[Fire General] DB126:
This thread is for the fortunate subset of 5th Gen Fire devices that are rooted and rocking a custom ROM. It should also work on rooted FireOS (5.3.1 and below) that have both ads and OTA updates blocked.

There have been numerous posts regarding uneven performance while multitasking along with sluggish response after waking the device from a long slumber. Most recognize this is due to excessive swapping associated with limited user addressable RAM. While there are a number of incremental 'tweaks' that can marginally improve this behavior my objective was to realize a more substantial improvement with minimal effort, knob turning and side effects. To date I have realized the benefit (minimal lag; responsiveness approaching devices with twice the RAM; woohoo!) but still working on the automation that will make it largely transparent. Lacking the time to work on the latter I thought it best to toss out the high level config and let others, if interested, work through both validation and implementation details.

As an aside, I have used the same technique on a 2nd gen HD running CM 11 that had been shelved for many months due to the same issues. It now hums along at a respectable pace and is once again a joy to use.

The secret sauce is simple: expand zram space allocation and add a small, secondary swap file in a normally unused location in permanent storage.

Tools (or adb/shell/terminal commands for those with furry chests):

- EX Kernel Manager (EXKM) or other tool/technique that can manage zram parameters (note: I find current builds of Kernel Adiutor too unstable for this work)

- Apps2SD Pro or other tool/technique that can create/manage traditional swap files and swap space priorities

- BusyBox Installer (v1.27.2+) or other tool/technique to insure startup scripts are properly executed

- L Speed (optional) - for ease of implementing a few discretionary performance tweaks

- DiskInfo PRO (optional) - visualize partition utilization

- RAM Truth (optional) - simple app to visualize RAM utilization

Technique (highly abbreviated):

- boot device to rooted ROM; install above tools or equivalents

- use EXKM to resize zram to 128 MB (note: zram must be temporarily disabled)

- use Apps2SD to:

* add a static, 128 MB swap file in the

cache partition

which remains largely unused with custom ROMs

*

important

: reassign swap file priorities (button at top right): 0 for the static file; 1 for zram

* increase swappiness to 100 if necessary (EXKM can also be used to set swappiness and other VM parameters)

* verify both swap spaces are enabled via sliders​

Note to geeks: I understand how swappiness, vcache pressure and other virtual memory tunings really work; let's not debate that here. Same with the merits of running a static swap file in combination with zram or the 'dangers' of placing that file in the volatile cache partition. We're talking a hand held device with very modest resources...not the server room with a 99.9x SLA. Yes, zswap would be better. However ... :)

Optional tweaks:

- use EXKM or L Speed to set LMK parameters to: 24, 32, 40, 48, 56, 64

- use EXKM or L Speed to set write deferral (aka 'laptop mode') to 5 sec

- toggle KSM off/on in L Speed (sets performance enhancing parameters)

- with zram disabled enable zram tweak in L Speed which will establish a 96 MB space along with other optimizations; I find the smaller size ideal for my workflow; YMMV zRAM size can be set with EXKM or another kernel manager.

Challenges:

While the options exist none of the tools noted above can reestablish custom zram space or automatically create a static swap file on boot. I believe this is a kernel issue but have not ruled out interference by Lineage 12.1 which is the ROM I have been testing with. Unfortunately, I lack the time (and quite frankly motivation) to toss Nexus or another ROM on to a spare device to verify the culprit. I might do a bit more testing my my HD 7 which uses a different kernel and ROM. --> Turns out an old version of BusyBox was the culprit; updating to 1.27.2 solved the problem allowing the suggested configuration to be automatically reestablished on reboot. I added my favorite BusyBox installer to the prerequisite tools.

Another issue is the potential for maintaining 'stale' annon pages in zram for a period of time but that's a left field item that probably won't effect most users. A quick fix is occasionally swiping away all apps.

Provide discussion/feedback in this thread. I may or may not respond depending on available time. I love a deep dive (shared above) but once the goal has been reached my interests move elsewhere.

Edit: struck-out references to L Speed after developer/maintainer acknowledged "cooperation" with Kingo Root team (borderline malware).