What is com.google.android.gms.persistent and why is it always using the CPU?

Even when nothing else is happening this system process seems to use a steady 1-2% of the CPU. Over the course of a day this drains a significant amount of battery even when the device wasn’t used for anything. I haven’t been able to correlate it to any other apps because even when they have only used a few seconds of CPU time each over the course of several hours this process is using minutes.

It still seems to run even if I:

  • turn off WiFi
  • turn off BlueTooth
  • turn off location services
  • turn off everything except the most bare minimum of syncing (e.g. GMail)

I wrote a little test app that monitors /proc/<pid>/stat every 10ms and writes to logcat any time com.google.android.gms.persistent, hoping that it would write something to logcat itself which would pinpoint what app or other service is using “persistent” for its services. I don’t see much, but here are a few things I did see:

InputReader: Reconfiguring input devices.  changes=0x00000010
WifiService: acquireWifiLockLocked: WifiLock{NlpWifiLock type=2 binder=android.os.BinderProxy@f73f0b8}
LocationFilter: Forcing stable location. Original location:Location[...
ConnectivityService: notifyType CAP_CHANGED for NetworkAgentInfo [WIFI () - 246]

Each line above was at a different time, immediately preceding (within 10ms of) a log message detecting CPU usage by com.google.android.gms.persistent but without any clear indication whether or not it is related. Unfortunately, none of the above reports more than 10ms of CPU time taken, and so – even if accurate in denoting what is using “persistent” represents only a small portion of the actual CPU time being used.

Other attempts to research what uses this process have suggested various things (such as wearables) which I don’t have and have never had connected to my device.

What is using this process? I am looking either for this information directly, or for additional ways I can deduce this information similar to my attempts via logcat.

Update: I have been looking for the source (e.g. com.google.android.gms.persistent.java or something like that) on https://android.googlesource.com without any luck. Is this not part of the public source code? What is really strange is that there doesn’t even appear to be any documentation, e.g. here: https://android.googlesource.com/platform/frameworks/base/+/33fca8e/docs/html/reference/com/google/android/gms

Update 2: I disabled all syncing under Settings -> Accounts. This seems to reduce CPU usage a bit more, and battery drop seems to have dropped to a crawl – except periodically com.google.android.gms.persistent still seems to take a burst of CPU.

My working theory now is that it has an Alarm that is firing at approximately 60 second intervals regardless of whether it is needed or not, and that code is checking for syncing work, and if nothing needs to be synced it gives up the time slice right away and lets the CPU go right to sleep. However, I halfway can’t believe that such a horrible design would be used, as anything that wakes up the CPU every minute is sure to drain the battery a lot faster even if it just goes back to sleep, and why would polling be used instead of something interrupt driven for syncing anyway?

As far as I can tell (due to not being able to find it) the source code for com.google.android.gms.persistent is not open source or available online anywhere. If I am wrong, I would accept as an answer to my question, any answer which would point to the source code as I could browse it and determine for myself why the CPU usage.

Leave a Comment