custodian / harbour-systemmonitor

Monitor SailfishOS for basic system activity
8 stars 10 forks source link

Adding support for CPU sleep; battery (dis)charging rates; cellular traffic reported via rmnet_usb #14

Closed rinigus closed 7 years ago

rinigus commented 8 years ago

This pull request includes several changes introduced into SysMon that I made while following SFOS port in Nexus 4 (mako). While I wanted to split this request into two, they got intermingled due to one commit. So, I'll submit all the changes together for your review.

Changes related to cellular traffic: app/qml/pages/CellPage.qml and daemon/datasourcecell.cpp

In Nexus 4 SFOS port (and probably some others), cell traffic is reported via rmnet_usb devices. As a result, original code ignored this traffic. Code has been changed to pull traffic info only from available files. This can potentially BREAK things if these files/dirs are created dynamically after SysMon daemon start. However, I am unaware of such possibility in practice.

Changes in all other files:

To debug battery charge consumption, I introduced the following changes:

  1. I added new CPU sleep data stream that is calculated using the difference in CLOCK_BOOTTIME and CLOCK_MONOTONIC. This difference shows the amount of time CPU is in sleep (used by mcetool). By recording relative change in clock times, we can get how much time CPU was in sleep between two measurements. In Nexus 4, that would be between 0 (no sleep) and 98% (only 2% time active) in some conditions. Since its directly related to battery, I added plot as a part of battery detailed information.
  2. I added plotting of battery charge rates (charge and discharge) as a part of battery detailed plot. Since the rates are calculated from battery charge %, no new data source was needed. The rates are calculated in app/systemmonitor.cpp when dataDerivative property of app/qml/pages/SysMonGraph.qml is set to true. The rates are calculated by hour (3600 s). While for charging autoscale of a plot seems reasonable and other settings can be specified in advance, I found that discharging rates could be interesting to study with different settings. Namely, the patch allows user to specify for discharge rate: maximal Y axis value, minimal time between data points used to calculate the rate, minimal changes in values when calculating the rate. The reasonable defaults are provided, user choices are saved as a part of configuration. User can change the parameters by clicking on discharge rate graph.

I have found that these changes helped me to find problems with faster than expected battery discharge. I expect that these would be useful for others as well.

custodian commented 8 years ago

I'll review the changes and merge to temp branch to split/squash commits.

rinigus commented 8 years ago

Thank you!

rinigus commented 8 years ago

I have worked on the code a bit further and since the original pull request has been done from master, then you receive all the following changes as well. You could consider them as well. Next time I'll try to remember to make a branch before submitting a pull request to keep them tidy.

There maybe an issue with treatment of cell data in the original pull request that I'll have to debug. I have a feeling that sometimes cell data reporting files are not available at the time sysmon daemon starts. At least I don't get the data always reported. I'll look into it a bit later, in few days, and would report back.

The recent changes were done to

I will probably release my version as an "Unofficial" one in OpenRepos, so more people could test and use it while you check and consider these commits.

rinigus commented 8 years ago

Hi!

Since I developed the code further, I suggest to organize the pull request better. Namely, in this pull request, there are too many different changes. I attached the pull request to master branch, but it would be better t make several branches that would correspond to different additions.

So, I suggest:

That should make it more concise and easier to review.

rinigus commented 7 years ago

closing as a part of a cleanup among my PRs