JackHack96 / dell-xps-9570-ubuntu-respin

Collection of scripts and tweaks to adapt Ubuntu running smooth on Dell XPS 15 9570.
996 stars 113 forks source link

Battery life optimization #74

Closed toonvanstrijp closed 5 years ago

toonvanstrijp commented 5 years ago

I love this respin but I would like to know how to optimze the battery performance.

I managed to turn off the (nvidia) GPU by installing prime-select and the gpuoff service which is in the original respin 9560.

But are there any more optimizations to be done to reduce the battery drain?

When I looked at powertop I saw that the fingerprint reader is using 1/2 W, and it doesn't even work. When I used sudo powertop --auto-tune this solved that issue.

When the laptop is idle it takes about 8 W, which I think could be lower. I think the wifi card consumes a lot more power than needed.

screenshot from 2019-02-09 11-45-16

I you want I can create a pull request with the current optimizations I did?

JackHack96 commented 5 years ago

Yes, it should be lower. In idle I get 5~6W. I deleted powertop --auto-tune because it shouldn't be necessary, as TLP should care about that. You wifi card is sucking up much power, try to check kernel version (I'm using XanMod Linux 4.20) and TLP config (/etc/default/tlp).

toonvanstrijp commented 5 years ago

@jackhack96 how did you disable the nvidia GPU? And I’m currently on 4.20 also, but I run Ubuntu 18.10 don’t know if that matters.

JackHack96 commented 5 years ago

It should be automatically disabled from bbswitch. gpuoff.service was used before the Ubuntu devs fixed a bug which was causing the GPU to not turn off.

toonvanstrijp commented 5 years ago

@JackHack96 what version of ubuntu are you using?

I'm running this kernel currently image

But the wifi powerdrain is still there.

JackHack96 commented 5 years ago

I'm using the 18.04 version, with Xanmod latest kernel. It could be a bug of 18.10, I don't know :(

toonvanstrijp commented 5 years ago

I've a problem with GNOME on 18.04 that my CTRL+ALT+T don't work (any a lot of other keyboard short cuts)

@JackHack96 how did you install the Xanmod?

toonvanstrijp commented 5 years ago

@JackHack96 can I create a respin with the xanmod already installed?

JackHack96 commented 5 years ago

@JackHack96 I never tried to make a respin already with xanmod. The keyboard thing is very strange, do xev register the shortcut call?

Anyway XanMod can be installed using the commands listed here: https://xanmod.org/#install_via_terminal

toonvanstrijp commented 5 years ago

@JackHack96 I'm not that experienced in linux, how can I see if xev is registering my shortcut call? And maybe we should do this in a different issue?

JackHack96 commented 5 years ago

Don't worry :+1: You can join on the Gitter chat if you want. Anyway, use this command for seeing if the keys are detected xev | gawk '/keycode/{if($0!=l)print;l=$0;}'. You just see the terminal that writes some output whenever a key is pressed

toonvanstrijp commented 5 years ago

Alright I did a complete reinstall of the ready to install iso you provided. So I'm running Ubuntu 18.04 now. When I open powertop this is the power usage: screenshot from 2019-02-09 21-11-49

I took a look at the devices at that could be turned off and what I saw was that the Goodfix fingerprint scanner and the nvidia are still consuming a lot of energy even when I selected my intel GPU using prime-select (and did a reboot).

screenshot from 2019-02-09 21-12-57

Any idea what I'm doing wrong? I would love to use Ubuntu but the battery life is terrible like this :p

JackHack96 commented 5 years ago

Probably it's not your fault...

Well, first update everything in your system. Then make sure you selected the Intel card with the command sudo prime-select intel (reboot just to be sure). Also install the proprietary nVidia drivers, because I couldn't let them in the respin, otherwise the system couldn't boot up.

Then check if the following command outputs auto: cat /sys/bus/pci/devices/0000\:01\:00.0/power/control If yes, then the nVidia card should be off.

toonvanstrijp commented 5 years ago

@jackhack96 I’ll give it a try, what nvidia driver are you recommending cause I’m seeing multiple versions.

And just to be clear, I don’t have to run ‘powertop —auto-tune’?

JackHack96 commented 5 years ago

I'm using 415 (sudo apt install nvidia-driver-415).

In theory it shouldn't be no longer needed to run powertop --auto-tune, TLP should care about it.

toonvanstrijp commented 5 years ago

Alright my nvidia seems to be off now :) and my power usage is now like this:

image

It's still quite hight right? (cause this is when it's on idle and the only thing I opened was chrome).

Also when I look at the usage per device image

You can see that the fingerprint device is using a lot of energy. Since this device doesn't have any driver installed my guess is, is that it won't turn off?

Also my keyboard shortcuts (CTRL+ALT+T) stopped working (many others too) I tried your script and this is what the output is when I tried hitting (CTRL+ALT+T) multiple times:

    state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    state 0x4, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    state 0xc, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    state 0x8, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    state 0xc, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
JackHack96 commented 5 years ago

When powertop says 100% it's clearly not right. The Goodix fingerprint isn't even supported by Linux (for now). Try measuring idle power usage without Chrome opened (only Budgie) and see if it settle at 6W, which would be normal.

For the shortcut, it seems Xorg is receiving the input, so it's a problem of the DE. Unfortunately, I never used Budgie so I can't help. Maybe there's a setting like in GNOME for keyboard shortcut, but I don't know. Try asking in the Budgie forums :)

toonvanstrijp commented 5 years ago

Yup it settles around 6W so I think powertop showing 100% at the Goodix fingerprint isn't a real problem.

Also I discovered that Ubuntu 18.10 has trouble handeling the nvidia GPU. In Ubuntu 18.04 cat /sys/bus/pci/devices/0000\:01\:00.0/power/control returns auto but in 18.10 it returns on.

Don't know what is going wrong there but at least everything seems to be working fine in 18.04 :)