Polochon-street / blissify-rs

bliss bindings for MPD.
29 stars 6 forks source link

--seed-song option failing #39

Closed kbridger closed 1 year ago

kbridger commented 1 year ago

I'm exploring using the --seed-song option. However it does not successfully run. I'm not sure if there are logs or ways to troubleshoot this.

/home/name/.cargo/bin/blissify playlist --seed-song 2 [2023-06-16T21:21:00Z WARN blissify] Could not find any MPD_HOST environment variable set. Defaulting to 127.0.0.1. [2023-06-16T21:21:00Z WARN blissify] Could not find any MPD_PORT environment variable set. Defaulting to 6600. Error: invalid pair

After this command completes (which takes 10-15 seconds) there are no changes to the MPD queue.

How can I troubleshoot the issue? I tried using gdb (I'm very rusty with that tool) but it reports that there are no debugging symbols found in blissify.

Polochon-street commented 1 year ago

Hi! Thanks for reporting this.

After some investigation, it seems that it is an error returned by the mpd library we use (probably here https://github.com/kstep/rust-mpd/blob/main/src/client.rs#L677).

Perhaps enabling MPD debug logging, and seeing what commands are sent to the MPD server by blissify would prove useful. Could you maybe paste that, if you find anything interesting?

kbridger commented 1 year ago

I switched mpd log_level to verbose (debug isn't a valid level I believe) and see a little activity in the log:

Jun 19 13:11 : client: [2] opened from 127.0.0.1:37894 Jun 19 13:11 : client: [2] process command "random "0"" Jun 19 13:11 : client: [2] command returned 0 Jun 19 13:11 : client: [2] process command "currentsong" Jun 19 13:11 : client: [2] command returned 0 Jun 19 13:12 : client: [2] timeout Jun 19 13:12 : client: [2] closed

So is mpd timing out the request? I'm asking for a seed-song value of 2 so should be not timing out? Will explore changing the timeout. Any other ideas?

kbridger commented 1 year ago

I used the connection_timeout config value for mpd to extend it to 10 minutes. I found that the command now completes just after 1 minute (which was mpd's default), and properly updates the queue.

I'm testing now with a seed-song 10 command to see how long it takes 10 songs. What kind of performance should I be expecting?

Edit: the 10 song command actually finishes very close to the 2 song. Like 1min 4 seconds total time. So I'm testing with 100 songs now. Is there just an initial investment like a minute, and then the number of songs doesn't really impact duration much?

Edit 2: 100 songs took 1 min 5 seconds.

Polochon-street commented 1 year ago

It is indeed an internal investment of a minute, and then it should be ~instant. What happens when you run --seed-song is that you compute a distance matrix for all the songs (distance between all the songs in your library - rather expensive), and then just do cheap lookup when you go from song1 to song2, from song2 to song3, etc.

There are better ways to do this, but that would need a significant time investment. They do it a bit better here https://github.com/CDrummond/bliss-mixer/blob/master/src/api.rs, but I need to look in more details :)

kbridger commented 1 year ago

Your response makes sense, thanks for looking into that for me!