beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.78k stars 1.82k forks source link

Import hangs on Goldberg Variations #609

Closed msolli closed 10 years ago

msolli commented 10 years ago

I'm importing a large-ish collection of music into beets. The import seems to hang on one particular recording. I've tried several times, and waited for up to three hours. It always hangs at the same spot. The process won't terminate with CTRL-C, I have to kill -9 it.

Here's the output when I try to import only the problematic recording:

$ beet -v import Music/iTunes/iTunes\ Media/Music/Bach,\ Johann\ Sebastian\ \(1685-1750\)/Bach_\ Goldberg\ Variations\ \[Gould\ 1981\]/
data directory: /Users/marsolli/.config/beets
library database: /Users/marsolli/Music/Beets/library.blb
library directory: /Users/marsolli/Music/Beets
Sending event: import_task_start
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/01 Goldberg Variations_ Aria.mp3'
chroma: matched recordings [u'5c4f8df3-363d-4523-9519-4d37600c1a28', u'd57d7065-020f-4648-b1ca-12c9ba72f78d', u'f5b7852b-3d83-44c0-becd-fddd75fd9dbd']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/02 Goldberg Variations_ Variation 1.mp3'
chroma: matched recordings [u'efb39634-473c-4464-9bb0-f1656173304c']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/03 Goldberg Variations_ Variation 2.mp3'
chroma: matched recordings [u'2aaaf99c-8060-4b17-a932-89280e972c91', u'2f30b299-2ab4-451b-a8a8-bfb0992846cc', u'aaa35cd1-08d2-4d1f-bda5-b82faa58deaf', u'cde1a2e1-804f-4e92-ba1c-525b06780452', u'd2e136ac-db4b-4552-90fa-bfcfa24b9760']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/04 Goldberg Variations_ Variation 3.mp3'
chroma: matched recordings [u'2b90147a-f27f-465d-9ac0-5e7aebdd37c2', u'398013da-7174-4e27-92b4-69be848c5f2a', u'88e17b8d-492b-4cc9-8e02-e4de08e3dc79', u'8d7588f3-9ac0-42b5-8086-a1994065dc95', u'ec697868-2002-4622-8981-53b81a020924']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/05 Goldberg Variations_ Variation 4.mp3'
chroma: matched recordings [u'13014434-699d-4ef7-a449-bdb8d7461ba8', u'387c58bf-69e1-4459-8dbb-ce21613b6922', u'420362c4-7b0a-40c4-b111-7d75ef519988', u'a620a6f0-41a0-47f8-a993-17a76a2cb6b8']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/06 Goldberg Variations_ Variation 5.mp3'
chroma: matched recordings [u'270dcac7-ed7b-4b13-9fb0-939d20ebc2ce', u'3f80b5bc-173c-4b57-8079-eecbddda2dce', u'458f6e29-0a5e-4d81-ae97-645edf76ee2d', u'8b0addf2-db34-47be-9d9d-650b20efa153', u'9d126e3a-a0ac-493f-833a-f7cf79b3ac0a', u'b8b48128-eb80-486c-b640-c8d05f6e6f8a', u'cafbb9ca-de34-40d5-bda2-fef49c7c3714']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/07 Goldberg Variations_ Variation 6.mp3'
chroma: matched recordings [u'22bb0a41-9c6a-46a2-a156-537dc0696f95', u'230cca97-989c-467a-ace0-53d262285360', u'5187687e-bc85-4468-8605-f30ae6ffb009', u'67bff0ec-8f5c-47b6-a539-1f53f4b9b7f5', u'ba67c3e6-5d43-4f93-b673-7d2f5c3026aa']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/08 Goldberg Variations_ Variation 7.mp3'
chroma: matched recordings [u'12ddea73-678e-4fb9-981f-06f116abcb2b', u'8975325b-540c-4888-ac8a-7eaee675bfa1', u'945d71c6-f230-44d9-91da-abc28be2ccb2', u'df22c486-2e50-4111-981d-11723871bb52']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/09 Goldberg Variations_ Variation 8.mp3'
chroma: matched recordings [u'0a072b85-f098-464e-b48a-ba74933ca037', u'243d0a02-c649-434b-adbd-686a86d452d6', u'321e4649-909f-4848-a406-f19a7ff56d3f', u'7d81a6ad-19e3-455f-8ce0-4f2a6cefef46', u'8630c04b-ed95-4ec6-86cd-89959a4b0844']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/10 Goldberg Variations_ Variation 9.mp3'
chroma: matched recordings [u'12cc8157-dd93-40f1-b320-ceeb233dd728']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/11 Goldberg Variations_ Variation 10.mp3'
chroma: matched recordings [u'37c73ac4-1ac0-47c2-ae65-c2601c07f576', u'71f3718d-4ff4-488c-9b9e-1671e9731906']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/12 Goldberg Variations_ Variation 11.mp3'
chroma: matched recordings [u'02230f01-6046-4efd-9417-7177d58a8719', u'7c17ce1b-f9a3-4369-ba2d-3285cc50fce9', u'91fe80c2-3e47-43fc-98ce-73d5a7da847f', u'cee55b28-9f83-4a1c-ba7b-f2ff750f34bf']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/13 Goldberg Variations_ Variation 12.mp3'
chroma: matched recordings [u'7979a016-e248-4e59-9bc4-95686899e22d', u'eeb6b284-7fb4-4e27-a04b-8d2270fde50e']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/14 Goldberg Variations_ Variation 13.mp3'
chroma: matched recordings [u'61846e01-dd88-4a16-82cc-166334df32aa', u'e4bf94e8-6bf5-4a02-ae38-11eed1134163']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/15 Goldberg Variations_ Variation 14.mp3'
chroma: matched recordings [u'147a507f-eb8b-4243-8c28-7792bbf73c71', u'23336eea-025e-4057-94bb-535659e2df22', u'db33a86e-da5d-496e-999f-34ba4d4ad93d', u'e148cb42-d70f-4c41-8405-e6e774058270', u'f45370a7-9b66-4c56-a051-9dc85d19827a']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/16 Goldberg Variations_ Variation 15.mp3'
chroma: matched recordings [u'71ae16bd-3d22-40f5-a1fb-9eca28dd9a4f', u'71f7e240-9f9e-4654-a321-e6cfac31418c', u'82387183-11b7-4fcd-828d-99f8d9ef2dd8', u'aad045b7-cb7e-47ed-9421-10b32c89f27b', u'eeeb9a7e-549f-440b-adfc-a8451d96610f']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/17 Goldberg Variations_ Variation 16.mp3'
chroma: matched recordings [u'beb4ba24-ab1a-4eac-899b-0a63d8686367', u'c2540063-58d1-4f90-8751-ccac7835a7f9', u'c938c6d2-10b1-4586-b006-bf681bf3b9e3', u'd4541b33-592b-47d4-9ce8-6ca9ca19c371', u'f981d5b2-409c-4024-960f-47f11ed4a023']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/18 Goldberg Variations_ Variation 17.mp3'
chroma: matched recordings [u'200dd8bb-e0ff-4dba-9a52-3c2cae04f63e', u'4bedea05-82f5-4a0f-ab72-3f337474e86b', u'5769ea86-855a-41f2-9ffc-bace2f1d45a6', u'8f0ca846-1e8d-49c1-98a0-765bcd7340b9', u'd2d8b0d4-faa3-49d9-a7b2-37162c33c72d', u'dee6bf60-184b-4113-9a9e-3ad09f099214']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/19 Goldberg Variations_ Variation 18.mp3'
chroma: matched recordings [u'0270939d-c8d5-4147-8b1b-74df388c9f3d', u'10e9504f-7b85-4284-aa62-a41826980c11', u'29b94490-8df4-42b3-bdaf-0e48bac091bf', u'49b6802b-4314-4a66-819c-98b2874c61f6', u'6fdf8453-9fee-47d5-aa2a-657666acb9ba', u'77fc2fca-a5b0-43f1-b922-2aaea04055c4']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/20 Goldberg Variations_ Variation 19.mp3'
chroma: matched recordings [u'3c81ae24-560a-45a4-90bf-7c43f3b6a559', u'411966d5-ac10-4b3b-9bef-5d404df20c4b', u'87728147-be4f-4c79-8e13-3686ca1b877d', u'a0a03700-4c04-44bd-a37e-39e172567f4e', u'd38c92e0-a93d-4cb8-8943-0d41ce74336c', u'dd00c54c-bb0b-4c91-a41b-167bacefb396', u'f6f6e65e-8b71-4690-8d9d-eb4bdb4c5d7a']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/21 Goldberg Variations_ Variation 20.mp3'
chroma: matched recordings [u'0347f093-ab47-4f0f-a953-b35215f83226', u'58011b5f-08c2-46ca-848d-5b80aea5d21c', u'88483ce5-98ec-47ae-a477-7c5e2ce698bc', u'd3af6a38-af74-4dbe-8b84-cef52cf0f6e0', u'df6eca23-d626-4d7a-a21b-358eebeed4ac']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/22 Goldberg Variations_ Variation 21.mp3'
chroma: matched recordings [u'7fb8b982-71aa-4d6d-8817-00812fa2e227', u'997f5470-4c5a-4025-b765-46de97084d63', u'a93cfa2b-7abc-4fd3-a651-d405cb0f9d49', u'b1cc40c7-4f0d-46d0-b8e6-62d1e8f4391b', u'cf8c5606-b3a0-4672-8bed-21c26e933409']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/23 Goldberg Variations_ Variation 22.mp3'
chroma: matched recordings [u'10eeb35d-fde9-41c7-b2e9-ee81d7ff28b5', u'2086bec1-7c31-4466-9b5a-d62079021b59', u'280da5f8-09ce-4e19-b5e6-135934cf07c2', u'7c042eca-dd7d-4dcc-9e23-2e641ef7800e', u'e971973b-e187-4be6-bbce-a3388eabb079']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/24 Goldberg Variations_ Variation 23.mp3'
chroma: matched recordings [u'2b96e7c4-81f4-40f0-9fd2-7c2f57ce1057', u'5052fa40-d82b-4ac5-a868-a21319d70790', u'597607eb-07de-47e9-869b-4cda303cb46d', u'a7cd22df-06d4-461d-a346-3dc691e5f7b6', u'd218fb1e-0c23-4332-9cc5-7b033bc6014b', u'da3f033b-8eb2-490a-a9cc-223b4f9c974e']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/25 Goldberg Variations_ Variation 24.mp3'
chroma: matched recordings [u'4c1b1e8d-229f-4c8a-8f39-997d3e877ad4', u'70d80067-455d-4412-9711-4108803139fc', u'abc7c01d-67ef-4fd0-ad31-af2a4028d0f3', u'ad1471b0-7673-4728-8746-97affec713fa', u'eb9e57e3-9568-47b6-8b36-94b4e1ac9279']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/26 Goldberg Variations_ Variation 25.mp3'
chroma: matched recordings [u'5d2f227b-e19f-4255-b315-a7d9244c4c77', u'6c468410-cf46-4eb8-b11c-ffb3037899cb', u'9cec85fc-169a-4d60-b38b-3142dd755261', u'a9d72441-3c0e-4bbc-becf-0133b4d65306', u'e8d65b16-4e48-45ab-b588-11abce29ba1d']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/27 Goldberg Variations_ Variation 26.mp3'
chroma: matched recordings [u'42e12091-9a28-4c95-8aaa-debf9f275301', u'6c36a5ac-cd01-4893-a8f2-c4ceb4f89bc5', u'71de69c6-0daa-4067-adf5-906db77c4d7c', u'bcd7b466-7292-4c9b-a7bb-54fe437492dc', u'e4695009-1a98-4a06-843e-6fc66d812fae']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/28 Goldberg Variations_ Variation 27.mp3'
chroma: matched recordings [u'8b108931-3ee7-499f-a862-7635ca426e9c', u'92c24eef-dce4-469d-9f81-1247a92653c1', u'cfd6545e-5d80-4d4d-b2b4-07fadbc25537', u'ee288e7e-82fe-40d5-bed4-8a300e353a78']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/29 Goldberg Variations_ Variation 28.mp3'
chroma: matched recordings [u'51374064-5d09-45c0-8173-a41c9b2652ec', u'9379654c-08df-4bf6-8f47-b863a8bdf8e6', u'd8781b3f-945a-4523-9620-50396fd876b2', u'f4a2f57f-07ce-4f0e-b9ee-40b127cdd1bb']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/30 Goldberg Variations_ Variation 29.mp3'
chroma: matched recordings [u'40e3da41-2f7e-4a6b-8083-64cb42ec9543', u'62cce702-a4f0-432b-9bb5-b3090a8088e6', u'6d0fd323-e2bd-4532-9281-9a97f80b106c', u'fcc251d6-c7b0-49c7-8973-d562ef7f6bdd']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/31 Goldberg Variations_ Variation 30.mp3'
chroma: matched recordings [u'0083efaf-1f1f-413e-b9da-cc1fc29f4788', u'6d8b1b5a-902a-45aa-b4fc-d67651830952', u'aa0f6a75-326b-4228-9300-892cbdbf9f33', u'efc5209e-b010-4d99-b783-b66ec1ffb9fa']
chroma: fingerprinted '/Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]/32 Goldberg Variations_ Aria (Reprise).mp3'
chroma: matched recordings [u'caa8cab9-557c-4b59-924d-e0f714b3e50e', u'dc2854da-3b16-4403-835b-ff2e15145094']
Looking up: /Users/marsolli/Music/iTunes/iTunes Media/Music/Bach, Johann Sebastian (1685-1750)/Bach_ Goldberg Variations [Gould 1981]
Tagging Bach, Johann Sebastian (1685-1750) - Bach: Goldberg Variations [Gould 1981]
No album IDs found.
Search terms: Bach, Johann Sebastian (1685-1750) - Bach: Goldberg Variations [Gould 1981]
Album might be VA: False
Discogs API Error: 404 Not Found (query: Bach, Johann Sebastian (1685-1750) Bach: Goldberg Variations [Gould 1981]
acoustid album candidates: 15
Evaluating 20 candidates.
Candidate: Johann Sebastian Bach & Canadian Brass - Bach: Goldberg Variations
Success. Distance: 0.601668
Candidate: Johann Sebastian Bach; Kimiko Douglass-Ishizaka - J.S. Bach: Goldberg Variations, BWV 988 (The Open Goldberg Variations)
Success. Distance: 0.795537
Candidate: Johann Sebastian Bach - Variations Goldberg
Success. Distance: 0.725577
Candidate: Johann Sebastian Bach - Variations Goldberg
Success. Distance: 0.774363
Candidate: Johann Sebastian Bach - The Goldberg Variations, BWV 988
Success. Distance: 0.630604
Candidate: Johann Sebastian Bach - J. S. Bach: Complete Edition

I'm running beets 1.3.3 on OS X 10.9.2 with Python 2.7.6 from Homebrew.

Here's my config:

directory: ~/Music/Beets
library: ~/Music/Beets/library.blb
plugins: scrub discogs chroma info
import:
  copy: yes
  write: yes
  resume: yes
  incremental: yes
  log: ~/Music/Beets/import.log
original_date: yes
match:
  preferred:
    media: ['CD', 'Digital Media|File']

Please let me know if there's any more info I could provide.

sampsyo commented 10 years ago

Thanks for the report—that's very mysterious. Is the any chance you can share a copy of the problematic music so we can reproduce it? (If you want to share privately, my email address is on my profile page.)

msolli commented 10 years ago

Thanks, I've emailed you a link to the recording.

sampsyo commented 10 years ago

Sorry for the delay while I got around to this. I'm able to reproduce this (even without discogs)—candidate matches get slower and slower and the process' CPU usage creeps up to 100%. Not sure what's going on here; some closer investigation is in order.

geigerzaehler commented 10 years ago

Just an idea: There is a 80 CD box set with a couple of hundred tracks, including the Goldberg Variations. May this brings down the bipartite matching?

sampsyo commented 10 years ago

Yep, the bottleneck I'm able to reproduce is indeed on that very large release. But the slow part seems to be the all-pairs distance calculation loop (it took a few minutes to get through the distance calculation and then a few seconds to run the bipartite matching algorithm). This 150-CD collection does even worse.

I'm going to try to profile one of these to determine why the track_distance calls are so expensive.

sampsyo commented 10 years ago

After a bit of profiling, I found some egregious waste of work in the track-matching machinery. See the above commit if you're interested in the details, but the high-order bit is that 80% of an album match's time was being wasted on reloading match weights from the configuration. That's fixed now; an overall match operation on the 80-CD box set was reduced in my benchmark from 80 seconds to 17 seconds.

This should make things much, much faster but not instant. A match on the larger 150-CD collection is still going to take a while (my benchmark says about 100 seconds), but hopefully this is not interminable on your machine, @msolli.

The next bottleneck is a the string distance calculation. On that larger benchmark, 70% of the matching time is now spent in string_dist. (FWIW, 15% is spent in the bipartite matching algorithm.) I'm going to open a separate issue about looking into faster Levenshtein implementations.