spotify-player icon indicating copy to clipboard operation
spotify-player copied to clipboard

Idle CPU usage

Open Icelk opened this issue 1 year ago • 14 comments

Describe the bug When spotify_player is not playing (only tested with the integrated streaming on), it still uses ~7% of 1 CPU core (on a modern Ryzen).

To Reproduce Open the app.

Expected behavior < 1%

Log and backtrace I the default config, though suspect this has something to do with image.

Environment

  • OS: Arch
  • Application version: 0.14.0
  • Application features: -F notify,image,lyric-finder,pulseaudio-backend,streaming,media-control --no-default-features

Icelk avatar May 28 '23 18:05 Icelk

FYI, it was ~0.7% of 1 CPU core for my M1 Macbook Air. It would be helpful if you can provide a video/pictures for a demonstration.

Why do you think that 7% is not a good number but <1%? Do you have any baselines for comparison?

aome510 avatar May 28 '23 19:05 aome510

I'll try to compile with other feature sets, to see if I can narrow it down.

Compared to spotifyd, which uses 0-1% while idle. Playback should consume more cpu than being idle, but for now playback only uses ~2%, which is great!

Icelk avatar May 30 '23 14:05 Icelk

Looks to be an issue even with all features disabled. I'll include the flamegraph. How often is the UI updated? IIRC, spotify-tui heavily throttled updates when the window wasn't focused (I don't know how to detect that in terminals). flamegraph

Icelk avatar Jun 06 '23 18:06 Icelk

How often is the UI updated

It's determined by app_refresh_duration_in_ms config option (default to be every 30ms). You can increase the value if the default one feels consuming too much CPU.

aome510 avatar Jul 15 '23 19:07 aome510

Thanks! Would it be possible to make that refresh interval 500ms when I'm not inputting anything into spotify_player, but 32ms when I interact?

Icelk avatar Jul 21 '23 00:07 Icelk

Also seeing CPU usage around 7% too.

jacksongoode avatar Sep 20 '23 18:09 jacksongoode

I'm seeing high CPU usage on my macbookpro11,3 under EndeavourOS usually in the mid 30% range. This is true while playing and running via cargo run --no-default-features. Generally a great alternative to spt but that's not really usable for me :disappointed:

johnend avatar Apr 10 '24 20:04 johnend

I've been neglecting the app's performance for a while as its CPU usage is relatively low for me. top also gives me around 7% w.r.t one core. The previous tool I used reports CPU usage w.r.t all cores, so the number is 1/8 smaller.

Now, as I'm more interested in performance optimization, I'll come back to this issue and try something.

aome510 avatar Apr 17 '24 00:04 aome510

@aome510 great app so far, however, I see also a significant CPU usage with defaults settings on macbook M1. ncspot in comparison is neglibible.

lbonvarl avatar Jun 06 '24 13:06 lbonvarl

@lbonvarl thanks for reporting. Can you share the number on your machines, e.g what are CPU usages of spotify_player and ncspot? It can provide a good baseline for me to optimize.

That said, kinda busy lately, so I didn't have the chance to pick up this yet.

aome510 avatar Jun 06 '24 13:06 aome510

Hello @aome510, I am on Macbook Pro 13in, 2020 M1 16GB Sonoma 14.5, using current iterm2 3.5 under zsh. spotify_player sitting idle not playing is at 35% CPU on task manager with defaults setting. I installed via "cargo install spotify_player --features lyric-finder".

Screenshot 2024-06-08 at 12 54 56 Screenshot 2024-06-08 at 12 55 05

I also did "samply record ./spotify_player" from "spotify-player/target/debug" after a cargo build

Screenshot 2024-06-08 at 13 04 39

lbonvarl avatar Jun 08 '24 11:06 lbonvarl

In comparison, same machine here is the data for ncspot installed via homebrew. CPU usage is when idle at 2-3% Screenshot 2024-06-09 at 12 52 58 Screenshot 2024-06-09 at 12 53 11 Screenshot 2024-06-09 at 12 56 58

lbonvarl avatar Jun 09 '24 10:06 lbonvarl

Hello @aome510, do you need any extra data for this issue ? Let me know.

lbonvarl avatar Jul 03 '24 09:07 lbonvarl