Zram customisation

Search This thread

kessaras

Recognized Developer
Sep 28, 2013
4,670
9,454
39
Athens
www.audioshow.gr
Google Pixel 8 Pro
hi,
fire_ram_by_tinetabulous-d5kglwf.jpg


i'm creating this new thread in order to help bring back to life our p880.


Android is like linux (of course it is)
it caches the background processes that are not currently in use and uses the physical ram for only the active apps.
But what happens if the app needs more physical ram ?

It has 2 ways to get it.

1. zram
2. swap

Let's go first with swap. Swap is slow, it uses the disk storage for "physical ram" but it's not a physical ram.
It only emulates the physical ram. What does this mean ? It does exactly what ram does.
But ram is at least 1 milisecond faster than hard disk. What ram does in 1ns (depends on the ram) the hard disk do it in 1ms (maybe more, depends on the disk).
Ram writes and reads every single "thing" the cpu needs to calculate and it's not found in L1,L2,etc cache...
Ram is our no1 upgrade on a pc hardware when we need to make it faster, because it cooperates with the cpu at everything. (cannot explain it with more simple words)

Zram on the other hand it's compressed physical ram. This way we sucrifice a very tiny amount of physical ram speed and cpu usage to compress the physical ram. But cpu and ram are 1 million times faster than the hard disk.

check your available ram

Code:
adb shell free

Anyway, below i will show you a way to double or triple your zram.

Download my attached file below,unzip and place it in /system/etc/init.d

Code:
adb root
adb remount
adb push <path to file>/97zram /system/etc/init.d/

check permissions and ownership.
They must be 755 and root:shell. If they are not, then do:

Code:
adb shell
su
chmod 755 /system/etc/init.d/97zram
chown root:shell /system/etc/init.d/97zram


Good. Now navigate back to /system/build.prop and open it like a text to edit it

At the end add the line:

Code:
persist.service.zram=200

200 is the size and it means 200% of the physical ram.
Of course you can use a lower value if you want.

Now reboot.

check again the available ram.

adb shell free

Surprise.
How much of ram do you have now ?
phys.ram + zram = ???

If you like it, hit thanks.

*If your init.d isn't executed on boot for some reason *maybe supersu blocks it *maybe the kernel has some mistake *for any reason ... you can use kernel adiutor to emulate init.d on boot.

**For those that don't have init.d support by their kernel , they must install busybox to install sysinit or/and init

***Those that don't have zram partition at all, too bad, change kernel because that one doesn't support zram at all.

XDA:DevDB Information
Zram and various tweaks for p880, Tool/Utility for the LG Optimus 4X HD

Contributors
kessaras

Version Information
Status: Stable

Created 2016-12-22
Last Updated 2017-03-22
 

Attachments

  • Screenshot_20161222_103133.png
    Screenshot_20161222_103133.png
    25.1 KB · Views: 1,658
  • Screenshot_2016-12-23-09-28-34.png
    Screenshot_2016-12-23-09-28-34.png
    18.9 KB · Views: 1,584
  • 97zram.tar.gz
    1,010 bytes · Views: 1,049
Last edited:

kessaras

Recognized Developer
Sep 28, 2013
4,670
9,454
39
Athens
www.audioshow.gr
Google Pixel 8 Pro
p880 full/all tweaks

this is a script that goes in pair with my 97zram script.

In addition now in this script i have set some tweaks , as many as i can and only those that are not harmful and can damage a phone.

open


- Better mount point flags
- Internal storage:
  • nomerges
  • nr_requests
  • lower safe read_ahead_kb
  • cfq scheduler
  • remove add_random (if its enabled in the kernel by default)
  • rq_affinity
- external storage:
  • nomerges
  • nr_requests
  • lower safe read_ahead_kb
  • cfq scheduler
  • remove add_random (if its enabled in the kernel by default)
  • rq_affinity
- Net and virtual memory:
  • tcp_congestion_control
  • disable_ipv6
  • dirty_writeback_centisecs
  • dirty_expire_centisecs
  • dirty_background_ratio
  • dirty_ratio
  • drop_caches
  • kernel.panic
  • min_free_kbytes
  • overcommit_ratio
  • panic_on_oom
  • full swappiness
  • vfs_cache_pressure
- Kernel customisations
  • disable ksm
  • lowmemorykiller
  • read_wakeup_threshold
  • write_wakeup_threshold
- Only the safe internet customisations
  • tcp_timestamps
  • tcp_tw_reuse
  • tcp_sack
  • tcp_tw_recycle
  • tcp_window_scaling
  • tcp_keepalive_probes
  • tcp_keepalive_intvl
  • tcp_fin_timeout
- Reduce Vibration strength


How to "install" it ? Simple. just like you "installed" the zram script.
Set exactly same permissions, set ownership to root:shell and reboot.
 

Attachments

  • 98balanced.zip
    1.1 KB · Views: 404
Last edited:

masmoe

Senior Member
May 31, 2013
258
55
Jakarta
Redmi 9 Power
hi,
i'm creating this new thread in order to help bring back to life our p880.


Android is like linux (of course it is)
it caches the background processes that are not currently in use and uses the physical ram for only the active apps.
But what happens if the app needs more physical ram ?

It has 2 ways to get it.

1.zram
2.swap

Let's go first with swap. Swap is slow, it uses the disk storage for "physical ram" but it's not a physical ram.
It only emulates the physical ram. What does this mean ? It does exactly what ram does.
But ram is at least 1 milisecond faster than hard disk, what ram does in 1ns (maybe less, depends on the ram, but not slower) disk does it in 1ms (maybe more maybe less, depends on the disk).
Ram writes and reads every single "thing" the cpu needs to calculate and it's not found in L1,L2,etc cache...
Ram is our no1 upgrade on a pc hardware when we need to make it faster, because it cooperates with the cpu at everything. (cannot explain it with more simple words)

Zram on the other hand it's compressed physical ram. This way we sucrifice a very tiny amount of physical ram speed and cpu usage to compress the physical ram. But cpu and ram are 1 million times faster than the hard disk.

check your available ram



Anyway, below i will show you a way to double or triple your zram.

Download my attached file below,unzip and place it in /system/etc/init.d



check permissions , owner and group.
Our current kernels now that are also compatible with f2fs do that by default, but you must check it , just in case they aren't set by default.




Good. Now navigate back to /system/build.prop and open it like a text to edit it

At the end add the line:



200 is the size and it means 200% of the physical ram.
Of course you can use a lower value if you want.

Now use kernel adiutor to emulate init.d on boot since it's not enabled by default.

Now reboot.

check again the available ram.

adb shell free

Surprise.
How much of ram do you have now ?
phys.ram + zram = ???

If you like it, hit thanks.

**The 98balance is just a gift from me.
Those are my default settings for everyday use.
Init.d can do anything if we have some time to manually make our own script.
Have fun

XDA:DevDB Information
Zram, Tool/Utility for the LG Optimus 4X HD

Contributors
kessaras

Version Information
Status: Stable

Created 2016-12-22
Last Updated 2016-12-22
I copy the file to /system/init.d by file explorer. I can set permisdion to 755 but I can"t change the group to shell (the only option is root)
Then I modified the build prop as suggested and activated emulated init in Kernel Adiutor.
After reboot my ram still not changed.
Any suggestion?

Sent from my LG-P880 using XDA Labs
 

kessaras

Recognized Developer
Sep 28, 2013
4,670
9,454
39
Athens
www.audioshow.gr
Google Pixel 8 Pro
I copy the file to /system/init.d by file explorer. I can set permisdion to 755 but I can"t change the group to shell (the only option is root)
Then I modified the build prop as suggested and activated emulated init in Kernel Adiutor.
After reboot my ram still not changed.
Any suggestion?
Use another file manager that has more options.
It works only if kernel supports init.d.
 

Danielcdar

New member
Apr 11, 2015
4
3
Did it only changed the swap or zram happens to be called swap when running "free"?

That was my output:
Code:
$ free -m
             total       used       free     shared    buffers     cached
Mem:           968        936         32          0          1        279
-/+ buffers/cache:        655        313
Swap:         1453         30       1422

Edit:
Forgot to mention:
Code:
persist.service.zram=150
 
Last edited:
  • Like
Reactions: Phil_Smith

kessaras

Recognized Developer
Sep 28, 2013
4,670
9,454
39
Athens
www.audioshow.gr
Google Pixel 8 Pro
Did it only changed the swap or zram happens to be called swap when running "free"?

That was my output:
Code:
$ free -m
             total       used       free     shared    buffers     cached
Mem:           968        936         32          0          1        279
-/+ buffers/cache:        655        313
Swap:         1453         30       1422

Edit:
Forgot to mention:
Code:
persist.service.zram=150

exactly. good job. swap is called anyway. there isn't a word like zram anywhere. zram we call it because we use the ram to swap not the hard disk :good:
 
  • Like
Reactions: Danielcdar

Danielcdar

New member
Apr 11, 2015
4
3
exactly. good job. swap is called anyway. there isn't a word like zram anywhere. zram we call it because we use the ram to swap not the hard disk :good:

Cool, but, for it to work I had to manually run
Code:
swapoff /dev/block/zram0

Tried adding
Code:
busybox swapoff dev/block/zram0
To your script, but, I guess the rest of the script is executed before it finishes "cleaning" the swap, and I am no programmer.
 

kessaras

Recognized Developer
Sep 28, 2013
4,670
9,454
39
Athens
www.audioshow.gr
Google Pixel 8 Pro
Cool, but, for it to work I had to manually run
Code:
swapoff /dev/block/zram0

Tried adding
Code:
busybox swapoff dev/block/zram0
To your script, but, I guess the rest of the script is executed before it finishes "cleaning" the swap, and I am no programmer.

busybox echo 1 > /sys/block/zram0/reset
does swap off too why add
busybox swapoff dev/block/zram0 ?

but you gave me a great idea too for those that don't have init.d support in the kernel.
they can also download busybox to add init.d support. these days that i will have some free time i will improve it.
does not work for you ? if you want it to wait before it creates the new zram, give it the command
sleep 1
1 is time in seconds = 1 second
make it wait as much time you want

I am on AOSP 7.1.1 and use es explorer pro.
Are any option in Developer menu should be activated? Or should I install adb application?
Btw I use Termux for terminal.

Sent from my LG-P880 using XDA Labs

es explorer never shows the group shell right ?
use root explorer or enable adb and do
Code:
adb shell
su
mount -o remount rw /system
chmod 755 /system/etc/init.d/97zram
chown root:shell  /system/etc/init.d/97zram
or in a terminal inside your p880

Code:
su
mount -o rw remount /system
chmod 755 /system/etc/init.d/97zram
chown root:shell  /system/etc/init.d/97zram
 
Last edited:

kessaras

Recognized Developer
Sep 28, 2013
4,670
9,454
39
Athens
www.audioshow.gr
Google Pixel 8 Pro
adb shell command not found. Is it missing something?

Sent from my LG-P880 using XDA Labs

adb is used to open a port on pc for communication with the phone.
when we are in the phone terminal we directly do the command without adb , adb shell, etc.
for example :
Code:
cat /proc/sys/vm/swappiness/

to see our swappiness
at my previous post i gave you other commands to use inside p880
 
Last edited:

masmoe

Senior Member
May 31, 2013
258
55
Jakarta
Redmi 9 Power
adb is used to open a port on pc for communication with the phone.
when we are in the phone terminal we directly do the command without adb , adb shell, etc.
for example :


to see our swappiness
at my previous post i gave you other commands to use inside p880
I succesfully change permisdion and owner. I activated emulated init.d by kernel adiutor also but my swap dize still not changed. Any hints?

Sent from my LG-P880 using XDA Labs
 

Top Liked Posts

  • There are no posts matching your filters.
  • 8
    hi,
    fire_ram_by_tinetabulous-d5kglwf.jpg


    i'm creating this new thread in order to help bring back to life our p880.


    Android is like linux (of course it is)
    it caches the background processes that are not currently in use and uses the physical ram for only the active apps.
    But what happens if the app needs more physical ram ?

    It has 2 ways to get it.

    1. zram
    2. swap

    Let's go first with swap. Swap is slow, it uses the disk storage for "physical ram" but it's not a physical ram.
    It only emulates the physical ram. What does this mean ? It does exactly what ram does.
    But ram is at least 1 milisecond faster than hard disk. What ram does in 1ns (depends on the ram) the hard disk do it in 1ms (maybe more, depends on the disk).
    Ram writes and reads every single "thing" the cpu needs to calculate and it's not found in L1,L2,etc cache...
    Ram is our no1 upgrade on a pc hardware when we need to make it faster, because it cooperates with the cpu at everything. (cannot explain it with more simple words)

    Zram on the other hand it's compressed physical ram. This way we sucrifice a very tiny amount of physical ram speed and cpu usage to compress the physical ram. But cpu and ram are 1 million times faster than the hard disk.

    check your available ram

    Code:
    adb shell free

    Anyway, below i will show you a way to double or triple your zram.

    Download my attached file below,unzip and place it in /system/etc/init.d

    Code:
    adb root
    adb remount
    adb push <path to file>/97zram /system/etc/init.d/

    check permissions and ownership.
    They must be 755 and root:shell. If they are not, then do:

    Code:
    adb shell
    su
    chmod 755 /system/etc/init.d/97zram
    chown root:shell /system/etc/init.d/97zram


    Good. Now navigate back to /system/build.prop and open it like a text to edit it

    At the end add the line:

    Code:
    persist.service.zram=200

    200 is the size and it means 200% of the physical ram.
    Of course you can use a lower value if you want.

    Now reboot.

    check again the available ram.

    adb shell free

    Surprise.
    How much of ram do you have now ?
    phys.ram + zram = ???

    If you like it, hit thanks.

    *If your init.d isn't executed on boot for some reason *maybe supersu blocks it *maybe the kernel has some mistake *for any reason ... you can use kernel adiutor to emulate init.d on boot.

    **For those that don't have init.d support by their kernel , they must install busybox to install sysinit or/and init

    ***Those that don't have zram partition at all, too bad, change kernel because that one doesn't support zram at all.

    XDA:DevDB Information
    Zram and various tweaks for p880, Tool/Utility for the LG Optimus 4X HD

    Contributors
    kessaras

    Version Information
    Status: Stable

    Created 2016-12-22
    Last Updated 2017-03-22
    2
    p880 full/all tweaks

    this is a script that goes in pair with my 97zram script.

    In addition now in this script i have set some tweaks , as many as i can and only those that are not harmful and can damage a phone.

    open


    - Better mount point flags
    - Internal storage:
    • nomerges
    • nr_requests
    • lower safe read_ahead_kb
    • cfq scheduler
    • remove add_random (if its enabled in the kernel by default)
    • rq_affinity
    - external storage:
    • nomerges
    • nr_requests
    • lower safe read_ahead_kb
    • cfq scheduler
    • remove add_random (if its enabled in the kernel by default)
    • rq_affinity
    - Net and virtual memory:
    • tcp_congestion_control
    • disable_ipv6
    • dirty_writeback_centisecs
    • dirty_expire_centisecs
    • dirty_background_ratio
    • dirty_ratio
    • drop_caches
    • kernel.panic
    • min_free_kbytes
    • overcommit_ratio
    • panic_on_oom
    • full swappiness
    • vfs_cache_pressure
    - Kernel customisations
    • disable ksm
    • lowmemorykiller
    • read_wakeup_threshold
    • write_wakeup_threshold
    - Only the safe internet customisations
    • tcp_timestamps
    • tcp_tw_reuse
    • tcp_sack
    • tcp_tw_recycle
    • tcp_window_scaling
    • tcp_keepalive_probes
    • tcp_keepalive_intvl
    • tcp_fin_timeout
    - Reduce Vibration strength


    How to "install" it ? Simple. just like you "installed" the zram script.
    Set exactly same permissions, set ownership to root:shell and reboot.
    2
    post #2. that's my last script for p880. I don't think i missed anything. If there is anything more you need , use feature request section and ask for anything.
    1
    In which ROM you have tested this?? And What kernel you had tested with.
    Aosp6. Works on aosp7 and all.
    Also works on almost any Rom. Omni,rr and more. It won't work only to kernels that don't support init.d
    1
    Hey guys,
    I try to put the 97zram file in init.d folder.
    But when I copy it from internal sdcard to init.d folder it says 'operation failed'.
    What am I doing wrong?
    Cheers

    maybe remounting system as rw before copying it inside ?
    use a better file explorer.

    ---------------------------------------------------------------------------------------------------

    22-03-2017

    - Updated instructions in the OP
    - Fixed bugs in the script in the 2nd post.