It was the MAME snap directory; I have a couple of these for different versions, and the one with 29k images definitely did it. I think so did the one with 10k, though.
The one that works OK is my menu_snaps folder, used for snaps for the menus only, and it only has 159 in it.
I haven't tried doing incremental tests, but I could if it would help. A binary search to find the tipping point would be tedious, but wouldn't take THAT long.
From watching it happen, I suspect it is something as simple as building the list of filenames to choose from, just taking too long.