Hi,

We recently observed that

1.  About half of the anonymous memory in b2g do not vary very often.
    We taked a snapshot after booting into lock-screen. After playing for a 
while[1], we taked the other
    snapshot. The common parts of the two snapshot are around 30MB out of total 
60MB anonymous memory.

2.  We tried to compress the anonymous memory in b2g and the compression ratio 
is 25% ~ 50%, depending on
    the compression methods.

It seems that we can take advantage of these characteristics. For 1, we might 
either

a.  Write those anonymous memory into files and map them back after booting so 
that they can be used as
    page caches and OS can evict them on memory pressure.
b.  Intercept mmap() to redirect all mmap(..., MAP_ANONYMOUS, ...) into files. 
This is very similar to a.
c.  Enable swap.

They all rely on that Linux kernel evicts clean pages first and then dirty 
pages. We must tune 
some parameters to strike a balance among performance, memory usage and the 
life of flash.

For 2, we might enable in-kernel memory compressions[2]. For example, zRam is 
an in-memory swap device that
pages are swapped in/out before/after decompression/compression, respectively. 
There's no write to flash.
We might in addition add some APIs to hint kernel. For example, when an 
application is lowered to
background, it is expected to be less active and becomes a good candidate to be 
compressed and swapped out.

What do you think?

[1] Open facebook and twitter and look around, take a picture, run sunspider 
and so on.
[2] http://lwn.net/Articles/545244/
_______________________________________________
dev-b2g mailing list
dev-b2g@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to