Firefox OS/Performance/Memory/ADB Tools: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 1: Line 1:
== b2g-ps ==
#REDIRECT [[FirefoxOS/Performance/Memory/ADB Tools]]
The <code>b2g-ps</code> command performs a simple process listing and filter out all non-b2g processes.  While it does not provide too much memory information, it is usable on production devices where <code>root</code> is not available.
 
The command provides:
 
* <code>RSS</code>: The combined, unique and shared, memory currently paged into the process as Resident Set Size.
* <code>VSIZE</code>: The virtual address space referenced by the process.  This will typically be larger than the actual memory in use.
 
<code><pre>
bkelly@lenir:/srv/gaia-master$ adb shell b2g-ps
APPLICATION      USER    PID  PPID  VSIZE  RSS    WCHAN    PC        NAME
b2g              root      292  1    183060 76256 ffffffff b6f0563c S /system/b2g/b2g
(Nuwa)          root      815  292  53304  20988 ffffffff b6ea963c S /system/b2g/plugin-container
Homescreen      u0_a958  958  815  72000  27420 ffffffff b6ea963c S /system/b2g/plugin-container
Communications  u0_a1303  1303  815  73388  26864 ffffffff b6ea963c S /system/b2g/plugin-container
Marketplace      u0_a1461  1461  815  89636  39760 ffffffff b6ea963c S /system/b2g/plugin-container
(Preallocated a  u0_a1512  1512  815  60476  18360 ffffffff b6ea963c S /system/b2g/plugin-container
</pre></code>
 
== b2g-info ==
 
The <code>b2g-info</code> command is available on devices flashed with an engineering build.  It requires <code>root</code> permissions to run.  It provides more detailed information than <code>b2g-ps</code> and also provides data on overall system resources.
 
Specifically, for each process <code>b2g-info</code> provides:
 
* <code>USS</code>: The memory unique to the process as Unique Set Size.
* <code>PSS</code>: Memory shared with other processes as Proportional Set Size.
* <code>RSS</code>: The combined, unique and shared, memory currently paged into the process as Resident Set Size.
* <code>VSIZE</code>: The virtual address space referenced by the process.  This will typically be larger than the actual memory in use.
 
For the overall system <code>b2g-info</code> provides:
 
* <code>Free</code>: Free memory not currently in use by any process.
* <code>Cache</code>: Memory currently holding files paged into a process.  These can typically be flushed back to disk to increase <code>Free</code> memory.  Of course, the running application will always need some part of its executable and library paged in, so this will never go to zero.
* <code>Free+Cache</code>: The effective total amount of memory the system considers "available" for new processes.
 
Finally, <code>b2g-info</code> provides some information about the thresholds at which it will attempt to kill processes.  When <code>Free+Cache</code> (or is it <code>Free</code>?) reaches the given <code>min_free</code> value then processes with the given calculated <code>oom_adj</code> score will be killed.
 
<code><pre>
bkelly@lenir:/srv/gaia-master$ adb shell b2g-info
                          |    megabytes    |
          NAME  PID PPID CPU(s) NICE  USS  PSS  RSS VSIZE OOM_ADJ USER
            b2g  292    1  75.5    0 57.7 63.1 76.7 178.8      0 root
        (Nuwa)  815  292    1.4    0  3.7  8.0 20.5  52.1      0 root
    Homescreen  958  815    5.5  18 11.1 14.4 27.4  70.3      8 u0_a958
Communications 1303  815    2.5  18 10.6 13.9 26.9  71.7      10 u0_a1303
    Marketplace 1461  815  198.4    1 22.7 26.4 40.1  87.5      2 u0_a1461
(Preallocated a 1512  815    0.6  18  5.2  7.6 18.2  59.1      10 u0_a1512
 
System memory info:
 
            Total 410.6 MB
    Used - cache 181.1 MB
  B2G procs (PSS) 133.5 MB
    Non-B2G procs  47.7 MB
    Free + cache 229.4 MB
            Free  96.7 MB
            Cache 132.7 MB
 
Low-memory killer parameters:
 
  notify_trigger 14336 KB
 
  oom_adj min_free
        0  4096 KB
      58  5120 KB
      117  6144 KB
      352  7168 KB
      470  8192 KB
      588 20480 KB
</pre></code>
 
== /proc/meminfo ==
 
The linux proc filesystem provides additional information about system memory resources at <code>/proc/meminfo</code>.  This can be useful if you want to breakdown system memory in a different way than <code>b2g-info</code>.
 
There is a lot of information available in <code>/proc/meminfo</code>.  For a description of the various fields please see the [http://linux.die.net/man/5/proc proc(5) man page].
 
<code><pre>
bkelly@lenir:/srv/gaia-master$ adb shell cat /proc/meminfo
MemTotal:        420412 kB
MemFree:          56936 kB
Buffers:          16796 kB
Cached:          136632 kB
SwapCached:            0 kB
Active:          159568 kB
Inactive:        131732 kB
Active(anon):    137884 kB
Inactive(anon):    8492 kB
Active(file):      21684 kB
Inactive(file):  123240 kB
Unevictable:          0 kB
Mlocked:              0 kB
SwapTotal:        196604 kB
SwapFree:        196604 kB
Dirty:                4 kB
Writeback:            0 kB
AnonPages:        137900 kB
Mapped:            48292 kB
Shmem:              8528 kB
Slab:              22008 kB
SReclaimable:      8664 kB
SUnreclaim:        13344 kB
KernelStack:        3056 kB
PageTables:        2280 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      406808 kB
Committed_AS:    248120 kB
VmallocTotal:    499712 kB
VmallocUsed:        3396 kB
VmallocChunk:    409764 kB
</pre></code>
 
== /sys/kernel/debug/ion/iommu ==
 
Starting in Android in Jelly Bean (JB) the system now uses the [https://wiki.linaro.org/BenjaminGaignard/ion ion memory allocator] for graphics shared buffers.  Due to the complexity of the graphics system this can often be a source for resource exhaustion or other problems.
 
On some devices the kernel provides debug information about ion memory use at <code>/sys/kernel/debug/ion/iommu</code>.
 
Note, on Firefox OS this will report allocations still in use as "orphaned" when they are actually not really leaked.  It seems this is related to our multi-process architecture.
 
<code><pre>
bkelly@lenir:/srv/gaia-master$ adb shell cat /sys/kernel/debug/ion/iommu
          client              pid            size
----------------------------------------------------
    adsprpc-smd                1            8192
----------------------------------------------------
orphaned allocations (info is from last known client):
        Browser            1758          294912 0 1
    Marketplace            1461          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
            b2g              292            4096 0 1
        Browser            1758          294912 0 1
    Marketplace            1461          294912 0 1
    Marketplace            1461          294912 0 1
    Marketplace            1461          294912 0 1
    Marketplace            1461          294912 0 1
        Browser            1758          294912 0 1
            b2g              292            4096 0 1
            b2g              292            4096 0 1
        Browser            1758          294912 0 1
    Marketplace            1461          294912 0 1
        Browser            1758          294912 0 1
        Browser            1758          294912 0 1
    Marketplace            1461          294912 0 1
    Marketplace            1461          294912 0 1
    Marketplace            1461            4096 0 1
            b2g              292          1536000 0 1
            b2g              292          1536000 0 1
    Marketplace            1461            16384 0 1
        mdss_fb0              350          1536000 0 1
            b2g              292          1536000 0 1
    Marketplace            1461            16384 0 1
    Marketplace            1461            16384 0 1
    Marketplace            1461            16384 0 1
    Marketplace            1461            16384 0 1
  Communications            1303          294912 0 1
  Communications            1303          294912 0 1
----------------------------------------------------
  total orphaned        14499840
          total          14508032
----------------------------------------------------
Cached Pools:
0 order 9 highmem pages in pool = 0 total
0 order 9 lowmem pages in pool = 0 total
0 order 8 highmem pages in pool = 0 total
0 order 8 lowmem pages in pool = 0 total
0 order 4 highmem pages in pool = 0 total
0 order 4 lowmem pages in pool = 0 total
0 order 0 highmem pages in pool = 0 total
3810 order 0 lowmem pages in pool = ee2000 total
Uncached Pools:
0 order 9 highmem pages in pool = 0 total
0 order 9 lowmem pages in pool = 0 total
0 order 8 highmem pages in pool = 0 total
0 order 8 lowmem pages in pool = 0 total
0 order 4 highmem pages in pool = 0 total
0 order 4 lowmem pages in pool = 0 total
0 order 0 highmem pages in pool = 0 total
0 order 0 lowmem pages in pool = 0 total
Total bytes in pool: ee2000
</pre></code>

Revision as of 20:05, 25 April 2014