[GH-ISSUE #160] Sucking up too much of my CPU #78

Closed
opened 2026-03-02 23:44:19 +03:00 by kerem · 7 comments
Owner

Originally created by @vannotz on GitHub (Mar 19, 2023).
Original GitHub issue: https://github.com/aome510/spotify-player/issues/160

Spotify-player has the tendency to suck up way too much of my CPU, it usually hangs around the ball-park of 25% CPU usage with common spikes to 50% and sometimes (like when opening the program), it spikes up to 80%. It also has the tendency to suck up 100% of a single core, changing between which.
I have compiled spotify-player with the alsa-backend and image features if that's of any concern.
spotify-player-23-03-19-12:35.log
I am running on Artix Linux with the runit init system.

Originally created by @vannotz on GitHub (Mar 19, 2023). Original GitHub issue: https://github.com/aome510/spotify-player/issues/160 Spotify-player has the tendency to suck up way too much of my CPU, it usually hangs around the ball-park of 25% CPU usage with common spikes to 50% and sometimes (like when opening the program), it spikes up to 80%. It also has the tendency to suck up 100% of a single core, changing between which. I have compiled spotify-player with the alsa-backend and image features if that's of any concern. [spotify-player-23-03-19-12:35.log](https://github.com/aome510/spotify-player/files/11011688/spotify-player-23-03-19-12.35.log) I am running on Artix Linux with the runit init system.
kerem closed this issue 2026-03-02 23:44:19 +03:00
Author
Owner

@vannotz commented on GitHub (Mar 19, 2023):

I have changed some settings in my app.conf, I was refreshing some stuff too quickly and it was taking a hit on my CPU, although the problem of it spiking to 80% on startup still persists, it doesn't surpass 15% usage anymore, with no further spikes during session.

<!-- gh-comment-id:1475319945 --> @vannotz commented on GitHub (Mar 19, 2023): I have changed some settings in my app.conf, I was refreshing some stuff too quickly and it was taking a hit on my CPU, although the problem of it spiking to 80% on startup still persists, it doesn't surpass 15% usage anymore, with no further spikes during session.
Author
Owner

@aome510 commented on GitHub (Mar 19, 2023):

I have changed some settings in my app.conf, I was refreshing some stuff too quickly and it was taking a hit on my CPU
app_refresh_duration_in_ms: 0, cover_image_refresh_duration_in_ms: 0

Yeah, you're right, from the logs, it was because these two values are set to 0. I think the default values should work well.

Another thing I found interesting from the logs is

2023-03-19T16:36:23.876853Z INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 8478ms
2023-03-19T16:36:24.428732Z INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 9030ms
2023-03-19T16:36:26.309465Z INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 10911ms
2023-03-19T16:36:27.462850Z INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 12064ms

The 4 requests took really long time to finish, which I think is the reason for the 80% spike on startup. Do you happen to have a large number of liked tracks, playlists, saved albums, or followed artists? By large here, I mean more than 500 items. For comparison, here is what I have on a normal run on my account:

2023-03-19T17:37:56.446781Z INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 48ms
2023-03-19T17:37:56.644253Z INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 245ms
2023-03-19T17:37:56.656105Z INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 257ms
2023-03-19T17:37:57.145791Z INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 747ms

I only have 131 liked tracks.

<!-- gh-comment-id:1475339873 --> @aome510 commented on GitHub (Mar 19, 2023): > I have changed some settings in my app.conf, I was refreshing some stuff too quickly and it was taking a hit on my CPU > app_refresh_duration_in_ms: 0, cover_image_refresh_duration_in_ms: 0 Yeah, you're right, from the logs, it was because these two values are set to `0`. I think the default values should work well. Another thing I found interesting from the logs is > 2023-03-19T16:36:23.876853Z INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 8478ms > 2023-03-19T16:36:24.428732Z INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 9030ms > 2023-03-19T16:36:26.309465Z INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 10911ms > 2023-03-19T16:36:27.462850Z INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 12064ms The 4 requests took really long time to finish, which I think is the reason for the 80% spike on startup. Do you happen to have a **large** number of liked tracks, playlists, saved albums, or followed artists? By large here, I mean more than **500** items. For comparison, here is what I have on a normal run on my account: > 2023-03-19T17:37:56.446781Z INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 48ms > 2023-03-19T17:37:56.644253Z INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 245ms > 2023-03-19T17:37:56.656105Z INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 257ms > 2023-03-19T17:37:57.145791Z INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 747ms I only have **131** liked tracks.
Author
Owner

@vannotz commented on GitHub (Mar 19, 2023):

Do you happen to have a large number of liked tracks, playlists, saved albums, or followed artists? By large here, I mean more than 500 items.

Depends, I have 230 liked song and my artists+playlists+saved albums would probably total just around 100. I could get hid of quite a few, most of these are trash I saved years ago and never thought about them again. I could give it a clean up and try launching the program again.

<!-- gh-comment-id:1475386324 --> @vannotz commented on GitHub (Mar 19, 2023): > Do you happen to have a large number of liked tracks, playlists, saved albums, or followed artists? By large here, I mean more than 500 items. Depends, I have 230 liked song and my artists+playlists+saved albums would probably total just around 100. I could get hid of quite a few, most of these are trash I saved years ago and never thought about them again. I could give it a clean up and try launching the program again.
Author
Owner

@vannotz commented on GitHub (Mar 19, 2023):

Removing a good amount of liked songs, followed artists, liked albums, etc has indeed solved the CPU spiking issue and looking at the logs I cut down, for example, GetUserPlaylists, from 8478ms to 489ms. I guess I didn't notice how much junk I had saved up. Thank you for your help

<!-- gh-comment-id:1475424933 --> @vannotz commented on GitHub (Mar 19, 2023): Removing a good amount of liked songs, followed artists, liked albums, etc has indeed solved the CPU spiking issue and looking at the logs I cut down, for example, GetUserPlaylists, from 8478ms to 489ms. I guess I didn't notice how much junk I had saved up. Thank you for your help
Author
Owner

@braheezy commented on GitHub (Mar 21, 2023):

Just happened to randomly read this thread. I've got some metrics too.

I have over 4k liked Songs and similar absurd counts for liked Albums and Artists. Here's the request times. Check out that GetUserSavedTracks call!

2023-03-21T01:52:08.192740Z INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 1146ms
2023-03-21T01:52:13.984344Z INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 6938ms
2023-03-21T01:52:35.246645Z INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: 28200ms
2023-03-21T01:52:07.512793Z INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 466ms

Granted, this machine has a 13th gen i5. But CPU load was unnoticeable and startup time is quick. Slight expected delay in some of the menus as the data loads in.

<!-- gh-comment-id:1477181284 --> @braheezy commented on GitHub (Mar 21, 2023): Just happened to randomly read this thread. I've got some metrics too. I have over 4k liked Songs and similar absurd counts for liked Albums and Artists. Here's the request times. Check out that GetUserSavedTracks call! > 2023-03-21T01:52:08.192740Z INFO client_request{request=GetUserFollowedArtists}: spotify_player::client: successfully handled the client request, took: 1146ms 2023-03-21T01:52:13.984344Z INFO client_request{request=GetUserSavedAlbums}: spotify_player::client: successfully handled the client request, took: 6938ms 2023-03-21T01:52:35.246645Z INFO client_request{request=GetUserSavedTracks}: spotify_player::client: successfully handled the client request, took: **28200ms** 2023-03-21T01:52:07.512793Z INFO client_request{request=GetUserPlaylists}: spotify_player::client: successfully handled the client request, took: 466ms Granted, this machine has a 13th gen i5. But CPU load was unnoticeable and startup time is quick. Slight expected delay in some of the menus as the data loads in.
Author
Owner

@vannotz commented on GitHub (Mar 21, 2023):

I have a 8th i7 so I don't think the difference should be this massive to the point as I get 80% usage spikes and you don't even notice it but clearing up my tracks has solved the issue either way

<!-- gh-comment-id:1477213683 --> @vannotz commented on GitHub (Mar 21, 2023): I have a 8th i7 so I don't think the difference should be this massive to the point as I get 80% usage spikes and you don't even notice it but clearing up my tracks has solved the issue either way
Author
Owner

@aome510 commented on GitHub (Mar 21, 2023):

Look like this issue is resolved by you @vannotz. I'll close it for now. Feel free to reopen if encounter any related issues.

<!-- gh-comment-id:1478159270 --> @aome510 commented on GitHub (Mar 21, 2023): Look like this issue is resolved by you @vannotz. I'll close it for now. Feel free to reopen if encounter any related issues.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#78
No description provided.