[vlc-devel] [RFC] Directory access: use a decent insertion?order
Rémi Denis-Courmont
remi at remlab.net
Sun Feb 14 19:31:20 CET 2010
Le dimanche 14 février 2010 20:06:00 Antoine Cellerier, vous avez écrit :
> > But what I'm most afraid is the I/O. Currently, one Block() call = one
> > readdir() call, so the I/O latency is as short as possible. To sort a
> > directory, you need to read it all, and then sort it and then output. And
> > that will have much much longer latency for large directories.
>
> I'm sure that it's possible without adding any readdir() calls. Just a
> small memory usage increase (and a lot less asprintf calls unless I'm
> mistaken, we alrady store the full tree structure xml string description
> anyway). I'll give it a try tonight just to see what it would exactly
> imply and post it here for feedback.
You don't need to add a readdir() call, of course. But you can't anymore make
one call per Block() call. You will read the whole dir, sort it, and only
*then* output items, all of them for the directory. Typically, you'd use
scandir() here, which in fact hides all the readdir calls.
There are ways around it, such as spawning a new thread for I/O and proofing
our scandir wrapper against cancellation. Alternatively, reimplement scandir()
(yet again!) so that Block() does one readdir per call, but returns NULL most
of the time. That will look quite awfully complicated but it's doable. Either
way, in light of J-B's complaint, that seems like something for 1.2 at the
earliest.
--
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis
More information about the vlc-devel
mailing list