Skip to content

enable zram #179

Closed
Closed

Description

@eworm-de

Raspberry Pi is very limited in RAM. Can you please enable zram (CONFIG_ZRAM) in kernel config? Compressing in ARM CPU is still a lot faster than writing swap to sd disk (and save write cycles for storage media). Thanks a lot!

Activity

  1. licaon-kter commented on Dec 30, 2012

    @licaon-kter

    needs:
    CONFIG_ZSMALLOC=m
    CONFIG_ZRAM=m
    but this might need more scripted support too, like to make or move a swap partition on a /dev/zramX device, or folders like /tmp and /run

    also, CleanCache & FrontSwap are nice to have and they do not need extra scripting work to have an effect:
    CONFIG_CLEANCACHE=y
    CONFIG_FRONTSWAP=y

  2. Ferroin commented on Dec 30, 2012

    @Ferroin
    Contributor

    I can say from experience that CleanCache and FrontSwap improve overall system performance.

  3. krisan commented on Jan 2, 2013

    @krisan

    how can I get this zram module working after firmware upgrade to 3.6.11+ ?

    Linux raspberrypi 3.6.11+ #348 PREEMPT Tue Jan 1 16:33:22 GMT 2013 armv6l GNU/Linux
    
  4. popcornmix commented on Jan 3, 2013

    @popcornmix
    Collaborator

    Any evidence on the effect of CleanCache and FrontSwap on performance when ZRAM is not enabled.
    They include the phrase "resulting in a negligible performance hit".
    The tracing options we had enabled a while back included that phrase and cost us 10-20% of performance.

  5. licaon-kter commented on Jan 3, 2013

    @licaon-kter

    I compiled them, any pointers on what tracing options you used and what/how should I test?

  6. popcornmix commented on Jan 3, 2013

    @popcornmix
    Collaborator

    These were the tracing options that proved expensive:
    5412f28
    Reduced iperf speed by 20% and xbmc framerate by 10%.
    Other possible benchmarks might be nbench and the quake timed demo.

  7. Ferroin commented on Jan 3, 2013

    @Ferroin
    Contributor

    You need to keep in mind that the tracing itself has non-neglible preformance implications.
    Just using some userspace benchmarks, i notice on average a 2-5% increase in latency when using the SD card for root and swap, and about 1-3% when using a USB connected SSD for both.

    The data might also be different between rev 1 and rev 2 hardware, because they use unallocated memory only, the numbers I listed above are for a rev 1 board, I'm picking up a rev 2 later this week, and can do the same checks on that board if you like.

  8. licaon-kter commented on Jan 4, 2013

    @licaon-kter

    stock freqs, kernel 3.6.11 as build 346

    nbench compiled as per Eben's challenge thread ( CFLAGS = -s -static -Wall -O3 -fomit-frame-pointer -funroll-loops -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard ):
    #346 stock: http://pastebin.com/2u0qtCnz
    #346+cleancache+frontswap: http://pastebin.com/2KF1wSiC

    quake3demo using my 2 demos ( mentioned here http://www.raspberrypi.org/phpBB3/viewtopic.php?f=29&t=6201&p=183723#p183723 and reuploaded here: http://www.sendspace.com/file/3vv92n ):
    #346 stock: 24.3fps / 36.1fps
    #346+cleancache+frontswap: 24.6fps / 36.3fps

  9. popcornmix commented on Jan 4, 2013

    @popcornmix
    Collaborator

    @licaon-kter
    sounds okay. Any difference in free memory after boot?

  10. licaon-kter commented on Jan 5, 2013

    @licaon-kter

    Not sure what you want me to check,but:

    • RPi Model B Rev. 1 w/ 256Mb
    • using a default /boot/cmdline.txt
    • using these settings in /boot/config.txt:

      gpu_mem_256=112
      cma_lwm=16
      cma_hwm=64
      cma_offline_start=16

    I get:

    • stock:

      total used free shared buffers cached
      Mem: 212M 64M 147M 0B 12M 29M
      -/+ buffers/cache: 22M 189M
      Swap: 99M 0B 99M

    • with Cleancache+Frontswap:

      total used free shared buffers cached
      Mem: 212M 64M 147M 0B 13M 29M
      -/+ buffers/cache: 21M 190M
      Swap: 99M 0B 99M

  11. popcornmix commented on Jan 7, 2013

    @popcornmix
    Collaborator

    Added these options. Use rpi-update and test please.

  12. licaon-kter commented on Jan 8, 2013

    @licaon-kter

    One thing that I've noticed, in my own kernel too, BogoMIPS number gets messed up, so usually BogoMIPS follows ARM core freq say 697 for stock or 849 ( when OC to 850MHz ), yet now with kernel #350 it's 547 for 850MHz. Any idea?

  13. licaon-kter commented on Feb 26, 2013

    @licaon-kter

    I just realized that zcache is not activated, can you
    CONFIG_ZSMALLOC=y
    CONFIG_ZCACHE=y
    it will activate some CONFIG_LZO_* too

    This is in staging, true, but it will not activate unless one adds the zcache keyword in the cmdline.txt so it won't affect anything else.

  14. popcornmix commented on Feb 26, 2013

    @popcornmix
    Collaborator

    I've added those options and looked at free memory after boot. We lose 168K.

    < Mem:        123956      51180      72776          0         28      27416
    < -/+ buffers/cache:      23736     100220
    ---
    > Mem:        123924      51320      72604          0         28      27420
    > -/+ buffers/cache:      23872     100052
    

    That seems a bit expensive for an option few people will use.

  15. 36 remaining items

  16. zerxy commented on Nov 4, 2014

    @zerxy

    Google think it helps. They're using it in Chrome OS. It certainly beats using swap on a slow SD card.

    marji: Download my zram enabled 3.10.59 kernel for the Pi at http://wikisend.com/download/264740/kernel.img

    With that kernel installed you can put 256 MB of swap (recommended for 512 MB Pi) on zram by doing the following:

    echo 268435456 > /sys/block/zram0/disksize
    mkswap /dev/zram0
    swapon -p 100 /dev/zram0

    Let us know how you get on.

  17. jurov commented on Nov 5, 2014

    @jurov

    Another option is to use older raspbian kernel that still supports it.

    Also when 256M is dedicated to zram, you can expect only max. 128MB real gain in usable virtual memory (it compresses only 2:1). It's best for occassional spikes, like gcc compilations. Might not help for sustained heavyweight memory hogs like LibreOffice.

  18. Ruffio commented on May 8, 2016

    @Ruffio

    Isn't zram build into the kernel already now?

  19. sultanqasim commented on Jun 21, 2016

    @sultanqasim

    Yes, it's built into the kernel now. It seems to improve performance and stability for me by avoiding applications getting killed due to OOM conditions. It's particularly good with multi-stream LZ4 compression. Here's the script I use to enable it on my Pi 3 and Pi 2 boards: https://gist.github.com/sultanqasim/79799883c6b81c710e36a38008dfa374

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions