A more indepth explaniton of procstats for Android - android

I am doing some memory testing and I came across procstats in my research - before I start using it though I would like to fully understand everything before I start relying on its data.
Here is a condensed file of what I am trying to work with:
CURRENT STATS:
* com.samsung.android.providers.context / u0a6:
TOTAL: 100% (4.2MB-4.2MB-4.2MB/3.3MB-3.3MB-3.3MB over 1)
Service: 100% (4.2MB-4.2MB-4.2MB/3.3MB-3.3MB-3.3MB over 1)
* com.sec.android.inputmethod / 1000:
TOTAL: 100% (28MB-28MB-28MB/27MB-27MB-27MB over 2)
Imp Fg: 100% (28MB-28MB-28MB/27MB-27MB-27MB over 2)
* com.google.android.googlequicksearchbox / u0a54:
TOTAL: 0.05%
Imp Bg: 0.05%
(Cached): 100% (4.8MB-4.9MB-5.0MB/3.2MB-3.3MB-3.4MB over 2)
* com.google.android.talk / u0a98:
TOTAL: 0.03%
Imp Bg: 0.03%
Receiver: 0.00%
(Cached): 100% (8.8MB-8.8MB-8.8MB/7.4MB-7.4MB-7.4MB over 2)
(Home): 100% (20MB-20MB-20MB/18MB-18MB-18MB over 1)
Run time Stats:
SOff/Norm: +24m36s393ms (running)
TOTAL: +24m36s393ms
Start time: 2014-12-08 14:22:50
Total elapsed time: +24m36s508ms (partial) libdvm.so chromeview
Here are the questions:
What does "over 1" / "over 2" mean?
What is the difference between Service, Imp Bg, Receiver, and Imp Fg?
Why doesn't every total list the RAM usage (com.google.android.talk for example)
What does 100% mean and what does .03% mean?
Why do only some have (Cached)/(Home)?
What does 100% (Cached)/(Home) mean?
What does "(partial) libdvm.so chromeview" mean?
Lastly, am I correct in assuming that (4.8MB-4.9MB-5.0MB/3.2MB-3.3MB-3.4MB) is (low pss - avg pss - high pss / low uss - avg uss - high uss)?
If anyone could shed any light on this is would be greatly appreciated. Thanks.
As a heads up, I've already read these two links.... android-developers.blogspot.com/2014/01/ and android.googlesource.com/platform/frameworks/base/+/master/core/ .... and a few other pages - these are still the questions that I have left over. Can anyone go into detail about all 8 questions?
Edit
So I have been trying to compare numbers between procstats and meminfo and it really only adds more questions.
Here is an excerpt from procstats
CURRENT STATS:
* com.dropbox.android:crash_uploader / u0a87:
TOTAL: 100% (4.8MB-4.8MB-4.9MB/3.9MB-3.9MB-3.9MB over 6)
Service: 100% (4.8MB-4.8MB-4.9MB/3.9MB-3.9MB-3.9MB over 6)
* com.mobileposse.client / u0a22:
TOTAL: 0.16%
Service: 0.13%
Receiver: 0.03%
(Cached): 98% (7.2MB-8.4MB-9.3MB/6.1MB-7.2MB-8.1MB over 7)
* com.android.chrome / u0a79:
TOTAL: 0.01%
Receiver: 0.01%
(Cached): 86% (5.2MB-5.2MB-5.4MB/4.4MB-4.4MB-4.4MB over 3)
Here is an excerpt from meminfo
Total PSS by process:
5524 kB: com.android.chrome (pid 7334)
4969 kB: com.dropbox.android:crash_uploader (pid 5617)
Now dropbox makes sense, and I would say 80% of the processes follow dropbox's lead with having matching numbers between meminfo and pocstats. What I don't get - why does chrome not have any totals in the procstats but is listed in the meminfo and why does mobileposse have higher stats than chrome in the procstats but is not listed in the meminfo?

Take a look to the sources linked by Alex P. You can find the answer to some questions there:
What does "over 1" / "over 2" mean?
That is the number of samples taken.
What is the difference between Service, Imp Bg, Receiver, and Imp Fg?
They are different states (Imp Bg means Important Background, and Imp Fg Important Foreground)
Why doesn't every total list the RAM usage (com.google.android.talk for example)
What does 100% mean and what does .03% mean?
% of the time that these apps have been running.
Why do only some have (Cached)/(Home)?
What does 100% (Cached)/(Home) mean?
What does "(partial) libdvm.so chromeview" mean?
Lastly, am I correct in assuming that (4.8MB-4.9MB-5.0MB/3.2MB-3.3MB-3.4MB) is (low pss - avg pss - high pss / low uss - avg uss - high uss)?
Yes, you are corrent, the documentation describes them as minPss-avgPss-maxPss / minUss-avgUss-maxUss

The percentages tell you how much of the overall time each process has spent in various key states. The memory numbers tell you about memory samples in those states, as minPss-avgPss-maxPss / minUss-avgUss-maxUss. The procstats tool also has a number of command line options to control its output — use adb shell dumpsys procstats -h to see a list of the available options.
Comparing this raw data from procstats with the visualization of its data we previously saw, we can see that it is showing only process run data from a subset of states: Imp Fg, Imp Bg, Service, Service Rs, and Receiver. These are the situations where the process is actively running in the background, for as long as it needs to complete the work it is doing. In terms of device memory use, these are the process states that tend to cause the most trouble: apps running in the background taking RAM from other things.
Quoted from: http://android-developers.blogspot.be/2014/01/process-stats-understanding-how-your.html Maybe you'll find more information using procstats -h or man procstats.

Related

Top command Android 8

I am trying to read (and understand) the CPU usage provided by the top command in my Samsung Galaxy S7.
From another post here I can see the explanation of the top command with the output that this person is getting.
However, when I go inside my Samsung using adb shell and I cal the top command, what I get is different from what the other used posted.
Am I doing something different/wrong?
If not, how do I read this output from top??
The output from the user on the other post has this:
User 5%, system 15%, IOW 0%, IRQ 0%
User 5 + Nice 0 + Sys 14 + Idle 73 + IOW 0 + IRQ 0 + SIRQ 0 = 92
PID CPU% S #THR VSS RSS UID Name
213 11% R 1 900K 340K app_16 top
However, the output from my top gives me something like that:
Tasks: 371 total, 7 running, 359 sleeping, 0 stopped, 0 zombie
Mem: 3618604k total, 3545056k used, 73548k free, 118980k buffers
Swap: 2097148k total, 894520k used, 1202628k free, 1441660k cached
800%cpu 9%user 0%nice 11%sys 780%idle 0%iow 0%irq 0%sirq 0%host
Basically, I cannot see the row
User 5%, system 15%, IOW 0%, IRQ 0%
which seems to be the key to understand the CPU usage.
Not really sure why, but "top" command is not longer accepting params on Android 8

Can someone please explain Android BatteryManger parameters

I am confused about the Battery Manager Parameters. can someone please explain below points:
BATTERY_PROPERTY_CHARGE_COUNTER -
Battery capacity in microampere-hours, as an integer.
Ques - Is it the remaining battery capacity or total battery Capacity.
If its total , why does it change
If its remaining( when i charged my phone 100% ) the values were somethign like 3366079 but total capcity of my phone's battery is 3300 mAh( read from power profile )
How can this be greater than 3300 mAh ?
Integer chargeCounter = mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CHARGE_COUNTER);
Integer capacity = mBatteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
Long energyCounter = mBatteryManager.getLongProperty(BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER);
long batteryCapacity = (chargeCounter/capacity) *100;
logs are as foolow :
Charge Counter: 3366079
capacity 100
Battery Capacity is :3366000
BATTERY_PROPERTY_ENERGY_COUNTER
Battery remaining energy in nanowatt-hours, as a long integer.
This parameter returns 0 ( tested on 2 devices )
Ques - Should this value be the remaining battery capacity value off 3300 mAH? or else what does this mean ?
Devices Used - LG G6 and Pixel 1
Thanks
There are a lot of physics behind these questions, for the first one,
How can this be greater than 3300 mAh ?
When manufacturers make a new battery they make them using a range, if your battery says it is 3300mAh there will be a range of error of +/- some error percentage.
Also to measure the battery they use a sensor which is prone to certain percentage of error too.
All these measures are converted from analog to digital which also conducts to another error.
I think this link could help: https://source.android.com/devices/tech/power/device
For your second question, check this post:
Android BATTERY_PROPERTY_ENERGY_COUNTER returning fixed value?

What the JobScheduler stats indicate

I have a repeating job scheduled using JobScheduler API in Android 7.0.
Please help me understand the following output of command:
adb shell dumpsys jobscheduler
u0a66 / < pkg >: 58x pending 5% 52x active
58 pending jobs, and 5 % (of total 52 running tasks) completed. /* 5 percent completed jobs id are stored in CompletedJobs queue to track */
adb shell dumpsys jobscheduler >> output.txt
gedit output.txt //read the complete output to get concepts
Commonly x is used to represent a number (how frequently).
I have an output something as below:
Current stats at 2017-07-25-01-42-38 (-5m30s657ms) over +5m30s657ms:
1000 / android: 2x pending 1x active
u0a14 / com.google.android.gms: 1x pending 1% 1x active-top
u0a66 / com.google.android.apps.photos: 3x pending 1x active
Max concurrency: 3 total, 1 foreground
Syntax:
/*<Uid> <reference> <app_name>: <% completed> <pending_jobs_count> <% completed>
<active_jobs_count> <status_that_tells_if_active_job_is_at_top_of_queue> */
It is a general understanding of how it should be. I can't provide you the link, so I am also not 100% certain. I just shared you my view.
JobScheduler is to effectively maintain the concurrency (from thread level -- called jobs). Even for the same program, there can be multiple processes (eg, service can start from the different process), and several threads. Ultimately these all threads are put in ThreadPoolExecuter and their operations are scheduled.
The job can be in pending, active and active-top state.
The u0a66 / package.name: 58x pending 5% 52x active line means that during that specified duration the package.name has 58 jobs in the pending state (which have been pending for less than 0.5% of the duration total), 52 jobs in the active state (which have been active for 5% of the duration total) and 0 jobs in the active-top state.

Android top process CPU usage is higher than user and system usage combined

I am trying to monitor CPU usage using the top command in my android phone, using the following command:
Process p = Runtime.getRuntime().exec("top -m 15 -d 1 -n 1");
One of the output's of the top command I got is this:
User 2%, System 9%, IOW 0%, IRQ 0%
User 3 + Nice 0 + Sys 10 + Idle 95 + IOW 0 + IRQ 0 + SIRQ 0 = 108
PID PR CPU% S #THR VSS RSS PCY UID Name
743 0 15% R 1 2416K 948K bg u0_a692 top
15351 0 2% S 79 1921396K 114536K bg u0_a59 com.google.android.googlequicksearchbox:search
167 0 1% S 6 9668K 3512K logd /system/bin/logd
496 0 0% S 1 0K 0K root kworker/0:3
20447 0 0% S 1 0K 0K root kworker/u:34
I am using a Nexus 4 which has a quad core chip i.e. 4 CPUs
Here the total CPU usage is (intuitively) user + system = 11%. However, the top process itself takes 15% of the CPU. It happens most of the time. Here's a graph which I plotted using running the top command at an interval of 1s.
As seen in most cases, the top command uses more CPU than user and system CPU usage combined.
What causes this behavior?
I wanted to calculate how much CPU is used in an idle, sleep state. So, I thought of subtracting the CPU used by the top process from the combined CPU usage of user and system. But, having these kind of output cannot help me to determine exactly how much CPU the phone is using.
Also, is the CPU% of a process the total of user and system? i.e. if a process is utilizing 10% CPU, is it actually using something like 6% user and 4% system CPU?

How to measure VRAM consumption on Android?

I want to acquire Android Device VRAM size.
Is there a method for acquisition from the program?
Let's do some calculation using Nexus One:
Screen resolution is 480x800. So minimum required video memory size would be:
400 * 800 * 4 bytes = 1536000 bytes
Assuming that driver may (and normally should) use several buffers, we should also expect values like:
1536000 * 2 bytes = 3072000 bytes
1536000 * 3 bytes = 4608000 bytes
etc...
It would be weird to have values that are not multiple of 1536000 (or W x H x 4 in general).
After some searches on Android internals I've found this documentation :
...Android makes two requirements of the driver: a linear address space of mappable memory that it can write to directly...accessing the driver by calling open on /dev/fb0...
So I tried and take size of /dev/graphics/fb0 file (on my device there is no /dev/fb0).
But a direct approach doesn't work:
File file = new File("/dev/graphics/fb0");
file.length(); // ==0, doesn't work, no read access
Using next trick you can get actual size of fb0:
>adb pull /dev/graphics/fb0
1659 KB/s (4608000 bytes in 2.712s)
Video memory is ~4mb (Nexus One). Let's check if this is multiple of Nexus screen size:
4608000/1536000 = 3
It looks like a right value. And we also can say that driver uses three screen buffers.
So, as a conclusion, you can detect video memory size using adb, but you can't use this approach from your android application in runtime due to file access restrictions.
You typically do not have a dedicated "VRAM" on mobile devices. At least you don't have it with PowerVR architectures (wich totally dominate the market with their MBX and SGX cores).
That is, the OpenGL driver allocates normal RAM until you run out of it, and the more you allocate the less you have left for your application.
The Android/OpenGL APIs don't offer explicit methods to read the VRAM size from a given device.
Poor man solution:
You could try to infer the VRAM size in an empiric way adding 1MB texture until you get an out of memory error from gl.glGetError().
From your "dmesg" output u can read off the VRAM, so for my Tablet:
> [ 0.000000] Machine: TDM3730 [ 0.000000] Reserving 12582912
> bytes SDRAM for VRAM
>
> 7>[ 3.929962] VRAM: checking region 9f400000 3072
> <4>[ 3.929992] Failed. Allocating 4194304 bytes for fb 0
> <7>[ 3.935333] VRAM: alloc mem type 0 size 4194304 paddr dec2bd4c
> <7>[ 3.935485] VRAM: checking region 9f400000 3072
> <7>[ 3.935485] VRAM: found 9f400000, end a0000000
> <6>[ 3.936584] android_usb gadget: high speed config #1: android
> <4>[ 3.960113] allocating 4194304 bytes for fb 1
or details at:
http://pastebin.com/jQSXQqHh
Is simple just count how many Mb ram that from usable to real capacity of the ram, example for my lenovo a369i has 512 RAM Module, but in setting app only showing 471 Mb usable so the 41Mb left is reserved for the GPU, so the conclusion is my a369i has 41Mb vram
This method is based from shared graphics memory (wiki)
I suspect that android.os.StatFs is what you're looking for:
http://developer.android.com/reference/android/os/StatFs.html

Categories

Resources