syncthing / syncthing-android

Wrapper of syncthing for Android.
https://syncthing.net/
Mozilla Public License 2.0
3.55k stars 397 forks source link

High Power Consumption #368

Closed ringelbaer closed 6 years ago

ringelbaer commented 9 years ago

Hello! Today I noted an excessive power consumption of the app (on the second day of use). Synchronization is turned on only in WLAN. There were seven photos to transfer (14 MB via WLAN) and this required 8% of the total battery power. The sync works beautiful, but the power consumption is to much! Syncthing Version: v0.10.30 Syncthing-Android Version: 0.5.28 Sony Xperia Z1 Compact Android 4.4.4

AudriusButkevicius commented 9 years ago

Are there two android devices involved by any chance? Also, it would be useful to see how much network traffic was consumed to sync these 14mb, as that could indicate that the power consumption is due to the protocol chatter.

ringelbaer commented 9 years ago

No, it's a sync between Android and Windows. Sadly I don't see the wlan network traffic of the app. No mobile data where used by the app (like the config is).

Am 22. April 2015 22:28:06 MESZ, schrieb Audrius Butkevicius notifications@github.com:

Are there two android devices involved by any chance? Also, it would be useful to see how much network traffic was consumed to sync these 14mb, as that could indicate that the power consumption is due to the protocol chatter.


Reply to this email directly or view it on GitHub: https://github.com/syncthing/syncthing-android/issues/368#issuecomment-95325844

Nutomic commented 9 years ago

You can see the traffic used in system settings ("Data Usage").

Duplicate of #349?

ringelbaer commented 9 years ago

okay, i missed the checkbox "view wlan". syncthing has consumed 50.94 MB (transferred files = 14 MB).

ManuelSchneid3r commented 9 years ago

Can confirm the high power consumption. Today 18% of my battery, for transferring 13,9MB of data (wlan usage).

strout commented 9 years ago

"Me too" here. Android app info claims >3h CPU usage (of 6h total uptime) and 840B (bytes) sent/received.

One of the directories I'm syncing has symlinks in a sub-subdirectory (from a Linux machine) that are repeatedly retried/failed. That may be contributing somehow; I'll try deleting them.

endolith commented 8 years ago

This is a problem for me, too. I tried to sync my SD card for backup purposes and the phone becomes very hot and locks up and becomes unresponsive whenever syncthing is running.

GLLM commented 8 years ago

Same here : battery drain is huge ...

1 folder sync'ed between Android 5.0.1 (Galaxy S4) and a server.

Hoping it will get solved in a foreseeable future ...

lkwg82 commented 8 years ago

@GLLM What is your version? I do have the same and everything was fine with android 4.4 and cm13 (android 6)

When you take a look into battery stats, how much percent is syncthing taking?

GLLM commented 8 years ago

Hi !

My Server/NAS are on both on v0.12.22

Phone is on Android syncthing v0.7.11 (i.e. Syncthing v0.12.20) > Edit : cos I'm using F-Droid repo :S

The app can take like ~20/25% of the battery consumption of my phone in <30min ... It's therefore unusable on a background sync basis.

So I launch it manually from time to time, then exit it + kill the process (simply exiting it on android does not stop the power leakage)

Thanks.

GLLM commented 8 years ago

I've tried what I was reluctant do to : remove the app (initially from FDroid) and installed the one on Google Play, which is in a higer version :+1:

So it's improved yet not perfect (Dropbox seemed to be using almost nothing even though it was syncing live)

Thx

wweich commented 8 years ago

The battery statistic isn't really accurate. After I activated the wake lock to prevent syncthing from being killed while the phone is in deep sleep, it changed from 2-3% to 10-18% in battery statistic, but the overall battery consumption (battery drain on a typical work day) didn't change a bit.

GLLM commented 8 years ago

Hi

I've upgraded to 0.7.15. And even thought battery stats are not accurate : my battery drain is still huge. And this drain did NOT happen prior to using Syncthing on my phone.

syncthing_battery_issue

Dont know what to do. But now I'm at 10% at 20h00, I was at 40 beforehand ... on average

GLLM

licaon-kter commented 8 years ago

Picture of Syncthing battery details? Picture of Syncthing network activity (mobile and/or Wi-Fi) details?

AudriusButkevicius commented 8 years ago

If its disconnecting often or sending a lot of data, battery usage is expected.

GLLM commented 8 years ago

Hello again,

I did not log for quite some time. Here's some feedback:

Today is (no new pics taken) syncthing_batt

batt2 batt3

It's getting annoying :(

What more info can I provide ?

Thanks.

licaon-kter commented 8 years ago

Look at that signal, why do you believe you have 4G/LTE there? That constant switching and searching (orange/red signal colour bar) eats up your battery.

Do this for a test, limit Syncthing only on Wi-Fi for a day (start at 100% battery) and see how that fares.

wweich commented 8 years ago

The battery meter from Android doesn't say much. When I enabled the experimental wake lock option, syncthing jumped from 2% to ~15% in the Android battery meter, but the real battery drain didn't really change.

GLLM commented 8 years ago

@licaon-kter I did stop the synchro over LTE and only kept that over WiFi and it basically stopped the battery drain. So it seems you were right. However, the same settings with Dropbox (sync over LTE, in the same place with the same average reception quality) never induces the same battery leakage, or at least not in the same order of magnitude... hence my surprise !

I'll keep the sync over WiFi for a while and consider if this has any drawbacks I cannot do with.

Cheers GLLM

capi commented 8 years ago

It might be that in your area you get a lot of re-connects when using LTE/3G (e.g. on every switch between those two technologies), causing a complete handshake to be sent. How was the data usage for Syncthing?

lkwg82 commented 8 years ago

relates to #671

micahscopes commented 7 years ago

I'm having this issue too. Only syncing over wifi. If there are stuck folders (out of sync master folders), syncthing can nail my battery in a matter of hours.

But even when "resting" (not syncing, no stuck folders), it seems to take at least 25% of my battery life. I'm hardly changing any files for this to happen. Compared to Resilio, which is taking a fraction of a percentage while resting.

@wweich I'm using GSAM to analyse the battery. It's much more accurate than the Android meter.

hubyhuby commented 7 years ago

TEST ON BATTERY LIFE: Syncthing 0.14.16 consum way too much battery on Android in IDLE scenarios. Running for 9 hours at night Syncthing consumed 14% of my battery doing nothing. This mean roughly in a 24Hours day it should be responsible for 35% of battery lost when doing nothing at all. I believe a Goal for this app would be to drain around 10% / day in IDLE scenarios (like this one). We are 2-3X too high.

TEC SPECS: Samsung galaxy a3 2016 Android 6.0.1 Dedicated relay server and @server with 5 persons using it Two android phone sync (with the other on off)

DATAS: I have lost 24% battery in 9H05 away from the power plug during a night Not using the phone during this test (network stanby Syncthing used 57% of the battery during this time (57% of 24% = 14%)

batterysyncthing

PS: Bonjour @GLLM , @AudriusButkevicius : I have exactly the same conclusions as you. I believe the problem is the IDLE consumption of power. This and the SD card not usable are big drawbacks for now ;)

micahscopes commented 7 years ago

I think it could do better even than 10%! Resilio Sync does very well when idle, and I'm not totally certain but I think it is more on the order of 3%-4% over a 24hr period.

On Mar 11, 2017 1:11 AM, "hubyhuby" notifications@github.com wrote:

TEST ON BATTERY LIFE: Syncthing 0.14.16 consum way too much battery on Android in IDLE scenarios. Running for 9 hours at night Syncthing consumed 14% of my battery doing nothing. This mean roughly in a 24Hours day it should be responsible for 35% of battery lost when doing nothing at all. I believe a Goal for this app would be to drain around 10% / day in IDLE scenarios (like this one). We are 2-3X too high. TEC SPECS: Samsung galaxy a3 2016 Android 6.0.1 Dedicated relay server and @server https://github.com/server with 5 persons using it

DATAS: I have lost 24% battery in 9H05 away from the power plug during a night Not using the phone during this test (network stanby Syncthing used 57% of the battery during this time (57% of 24% = 14%)

[image: batterysyncthing] https://cloud.githubusercontent.com/assets/26340942/23821415/ace7bb1c-0631-11e7-97cd-4d447184bf8a.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/syncthing/syncthing-android/issues/368#issuecomment-285849249, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXyll4UCIu46rKFFDE19AWMJCXwpdr6ks5rkkksgaJpZM4EGWbs .

Nutomic commented 7 years ago

@hubyhuby Android 6.0 is an unfortunate case, because inotify is broken. For this reason, we do folder rescans every 60 seconds with the default configuration. You can increase that interval in the web gui if thats okay for you.

hubyhuby commented 7 years ago

@AudriusButkevicius Thks. I have set the parameter for my rescanIntervals of my two folders to 300 (seconds I guess;). 1)BUT the value is always reseted to 0: -I save the parameters -If I go back RIGHT away it is still 300 -I go back in the normal GUI -I come back in web gui => back to default 0

2) I noticed many parameters there, and was wondering if some other could help with the battery issue ?

Thks for your help Yann

Nutomic commented 7 years ago

Do you save the folder settings after you change the rescan interval? It should also show the changed rescan interval after you close the folders settings. And I dont think any of the other settings would affect battery usage.

micahscopes commented 7 years ago

I was having an issue a while back where some of my folders had gotten stuck in this weird state where one or two files would get out of sync and remain that way. It caused some of my peers statuses to read "98%" perpetually. This really whammed the phone's battery life. I have since removed and added those folders back, which solved the stuck problem and the battery issue. I'm on Android 6.0.1 and Syncthing has consumed only 2% over 24+ hrs. When it was stuck, it was using 40%+ battery life, and would drain my phone in less than a day.

On Mar 11, 2017 4:20 AM, "Felix Ableitner" notifications@github.com wrote:

Do you save the folder settings after you change the rescan interval? It should also show the changed rescan interval after you close the folders settings. And I dont think any of the other settings would affect battery usage.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/syncthing/syncthing-android/issues/368#issuecomment-285857779, or mute the thread https://github.com/notifications/unsubscribe-auth/AAXyljgqEspRgCmHWT_WQAlWbbV9Qx92ks5rknVXgaJpZM4EGWbs .

hubyhuby commented 7 years ago

@AudriusButkevicius, @Nutomic , My problem is closed.

I am using my own compiled version of the project. Which is not supposed to change this behavior...but in the end is generating the bug wis the "rescanIntervals" ! To be sure I have installed your original V0.9.3 with sync 0.14.16 and it does work PERFECTLY for the parameter setup.

Thanks a lot for your help. Sorry for the disturbance. I will now make sure to report every issue with the original Syncthing for android installation.

hubyhuby commented 7 years ago

Dear @Nutomic , I have tried the latest version of Syncthing (not my compile;) ), on samsung galaxy a3 2017 android 6.0.1. Interestingely Samsung is providing a profiling of the Syncthing app over time. Which shows a huge increase of consumsion after 2 Hours. Also the phone keeps on saying we have to "optimise" the app, means shut it down ;) Even after you give all the usual autorisation to keep the app eating your batterie.

In short , users are prety much invited not to use syncthing, which is a problem I believe. Please note that I have NO folder synchtonised, Syncthing is just supposed to be sitting IDLE. An app like whatsapp that I use all the time consume 7%. And Syncthing IDLE consume 27% of my batterie in the same time :( screenshot_20170606-161758

screenshot_20170606-161837

screenshot_20170606-190143

Note: the A3 2017 is the 2nd most power efficient phone in the world as for today. And I "feel" when I start syncthing after few hours that I am not going to reach the end of the day... Even on a testing perspective I never let syncthing work more thant 2 to 3 hours! I really believe there is a factor 4X in improvement. If we could reach a factor 2X it would already mean we can use the app. Otherwise it is a no go for me at least ;)

hubyhuby commented 7 years ago

Hi @AudriusButkevicius , Now I think, I may have catched something more precise concerning battery usage after some testing. After some time (maybe around 1H30) on my device Samsung A3 2017 with android 6, I have 50% increase in CPU usage wether I have folder synchronised or not. This is CONSISTENTLY hapening at least on my device. Would be nice to have a confirmation from someone out there .

EDIT: the 1h30 thing comes I think from the samsung graph representation of consuption... But anyhow their is no reason there is a 50% increase in CPU... specially at 4AM while sleeping

screenshot_20170606-161758

Here I am using my modified version, but _ have exactly the same behaviour. Not that at 4AM in the morning I was sleeping....nothing was hapening on my phone: screenshot_20170705-054253

Nutomic commented 7 years ago

It would probably be helpful if you can catch some logs during that time. Possibly with debug flags enabled.

nicuh commented 7 years ago

Syncthing Version: v0.14.32 Syncthing-Android Version: 0.9.12 Samsung S6 Android 7.0

I had the same issue - the battery consumption was high. Even with a folder sync interval set to 3 days the folders where scanned approximately every 10 minutes. Also the Uptime of Syncthing binary was about 10-15 minutes. Which means the binary was restarted even the battery optimization was set to off. And on every restart, the folders are scanned.

I tried everything, all the combinations of settings, like Always run in background, with and without Sync only on wifi, with and without Run service with foreground priority - all without success.

In the end, the solution that worked for me was to disable restartOnWakeup in the advanced settings. It seems that Syncthing detects the phone is in standby and restarts itself:

Whether to perform a restart of Syncthing when it is detected that we are waking from sleep mode (i.e. a folded up laptop).

Before the change, Syncthing was in top 3 applications of battery consumption. Now it's not even in the list.

Here are the steps for disabling it:

capi commented 7 years ago

@nicuh Sounds interesting, need to dig into that.

Nutomic commented 7 years ago

I'm not having any trouble with battery usage, but if other people can confirm that disabling restartOnWakeup solves the problem, we could do that by default for everyone.

acolomb commented 7 years ago

I can confirm that it betters the situation on my device - LG G4 with LineageOS / Android 7.1.2. At least I have Syncthing backround processes now running for several hours at a time, until I lose my WiFi connection (run conditions active).

Sometimes I still get serious battery drain from a libsyncthing.so process eating one or two complete CPU cores, around 24 - 49% CPU usage according to the OS Monitor app. I suppose this is not syncthing-android's fault. May be related to #910? I will try to get some logging output when I catch it again and have some spare time.

Anyhow, restartOnWakeup = false by default seems like an essential improvement for the app to me. Otherwise a power-hungry rescan after each device sleep phase kind of renders sleeping pointless.

capi commented 7 years ago

As I use the foreground service option (otherwise Syncthing is killed off on my device), it doesn't make a difference, since my device never enters CPU sleep mode. But for people that don't need this, it really could make a difference, if Syncthing does not restart itself once it detects the clock forward jump after waking up from CPU sleep.

AudriusButkevicius commented 7 years ago

https://github.com/syncthing/syncthing/issues/565 is the ticket that is being addressed by this. Given it's very old, I'd say it would need more testing to see if everything works as expected without restarting.

I know for a fact things like UPnP and discovery will take some time to correct themselves, but it probably doesn't make much sense on a mobile anyway.

Nutomic commented 7 years ago

We could use the experimental options in the app for this. Then the question is just if we should set restartOnWakeup = false by default, or only let users do it themselves.

plittlefield commented 6 years ago

android_battery_syncthing_usage

Oh, it's not normally this bad.

Google Pixel (sailfish), Android 8.1.0, Syncthing for Android 0.10.5

wweich commented 6 years ago

Version 0.10.5 is broken, so it connects over and over just to get disconnected as soon as the index exchange starts. No wonder it uses so much battery.

plittlefield commented 6 years ago

OK, so just keep the charger close by for now until a fix? ;-)

Catfriend1 commented 6 years ago

According to https://forum.syncthing.net/t/question-about-restartonwakeup-setting/2222/14 restartonwakeup should be the default setting for syncthing android. image

Catfriend1 commented 6 years ago

I am working on the "restartonWakeup" option in the app.

Catfriend1 commented 6 years ago

It's implemented in the UI and migration PR #1051 mentioned above. Users with an existing configuration can manually toggle restartOnWakeup off in the app UI. Users creating a new configuration on first start of the app get restartOnWakeup by default.

AudriusButkevicius commented 6 years ago

Switching it off is not for free. You are trading battery usage for "my syncthing doesn't connect"

Catfriend1 commented 6 years ago

Lets see what new users report back. I am currently testing myself.

Catfriend1 commented 6 years ago

This discourse is over 3 years old, so we should at least give it a try as other users (see post above), calmh and me already found the battery saving the better option to live with on low-power devices. Plus, ignoring android doze syncthing core should not get in the state of being put to "standby" (timer increasing while app is frozen as interpreted by st core) so choosing between restartonwakeup or not is irrelevant to users living on Android 6+. Do you agree on having it easily configurable in the next version? That ensures, no one gets a showstopper when the change is released.

AudriusButkevicius commented 6 years ago

I agree in it being configurable, yet not disabled by default as the wider effect on all device base is not clear. Ideally this should come with a disclaimer explaining the effects.

If we are not being put into doze, then syncthing shouldn't be restarted, hence should not consume more battery.

Catfriend1 commented 6 years ago

@AudriusButkevicius: ok, I'll update the pr to make it enabled by default so no change is forced on new users. The disclaimer string will also be updated.