Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase tracklist.add batchSize #982

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mijofa
Copy link

@mijofa mijofa commented Mar 9, 2025

I have a playlist with over 8,000 local tracks in it. Iris took just over 2 hours to add this playlist to the queue.
I have over playlists of 500 tracks which only took a few seconds.

Seems the reason it's taking so long is because Iris is pushing only 5 tracks at a time. I understand there's efficiency reasons for this, but mpc clear ; mpc load ... ; mpc play took only <3 seconds with the same 8,000+ track playlist.
I've done some testing with an effectively infinite batchSize and had no problems at all, and was considering adding an extra zero to the batchSize in this commit to bump it up to 10,000, but figured there might be a real reason for this batching that should be discussed before going that far.

I'm not sure what specific symptoms I can test for "locks the Mopidy server", but this 1,000 batchSize let me add this 8,000 track playlist in ~30s.
Increasing it to 9,000 let me add this playlist in ~5s

@kingosticks
Copy link
Contributor

Fyi Mopidy 4 will use the faster JSON decoder/encoder that comes with pydantic and you might see even better performance numbers with your larger batch sizes. There are alpha releases available that you can try.

@jaedb
Copy link
Owner

jaedb commented Mar 11, 2025

This would be even more noticeable when fetching from an external provider (eg Spotify). The reason for batching is that fetching from remote providers takes a lot longer, and batches of 5 allowed a reasonably responsive mechanic for users to be able to cancel the action (rather than locking the server).

@kingosticks this was a bit of a bugbear when I was creating Iris, particularly with Spotify. My initial approach was to try and send the Mopidy the full JSON track object (as fetched by Iris via Spotify's HTTP API), rather than Mopidy also then needing to fetch the track (by ID).

Is there a way to create a Spotify Track object in Mopidy from a JSON object directly?

@mijofa
Copy link
Author

mijofa commented Mar 11, 2025

Ah fair, that makes more sense. I guess people also run this stuff on an rPi and similar devices.
Rather annoying that Mopidy doesn't have a single "add playlist" command so that the client frontend client doesn't have to deal with this. :/

In my circumstances, it's all local mp3 files, and 2 hours to load 1 playlist is a lot. Could we maybe scale the batchSize for different types of tracks? That's probably a little too much heavy lifting when you get down to playlists containing both local tracks AND spotify tracks though.

@kingosticks
Copy link
Contributor

It is possible to add an entire playlist to the tracklist by passing just the playlist uri. But that only works for some backend e.g. Mopidy-Spotify. Iris does its own thing with most Spotify content so I don't know if it's taking advantage of that.

It doesn't work for M3U playlists. That's fundamentally not currently possible with our architecture. It's frustrated me too for a long time. I think it would be a good reason to rethink our internals and make it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants