[Thunar-dev] Caching MIME information

Benedikt Meurer benedikt.meurer at unix-ag.uni-siegen.de
Tue Mar 29 22:20:31 CEST 2005


Jasper Huijsmans wrote:
>> In case you are not subscribed to the xdg mailinglist, there was a 
>> nice post by Matthias Clasen today, who came up with an idea about how 
>> to cache the MIME database information. See
>>
>> http://xfce-diary.blogspot.com/2005/03/caching-mime-information.html
>>
>> I'm not 100% sure if we can/should use it with Thunar, but I think 
>> it's worth a look, esp. since it could reduce startup time drastically 
>> if both the icon theme (done automatically by GtkIconTheme) and the 
>> mime database is cached.
> 
> Waldo Bastian seemed to agree, which would imply both GNOME and KDE will 
> use this cache. That's a pretty good reason to try and support it in 
> thunar as well.

I guess I spoke too early. Just read the patch again, and it looks like 
*all* magic comparisons are performed with every lookup that cannot be 
satisfied with the glob rules. Unfortunately, with the per mime 
directory cache, there seems to be no way to avoid this. There are 
currently about 162 magic rules. Now, the common case will be that a 
file matches on the glob pattern (unless the user/admin is a strange guy).

Anyways, I need to re-think this and maybe read the patch again. The 
major advantage for Thunar is reduced startup time (maybe). I guess I'll 
have to write test programs to measure the times and see if we'd really 
benefit from the cache.

I previously thought about having our own cache file, which then 
includes all rules from every mime/ directory in $XDG_DATA_DIRS, and 
inode/mtime pairs to support regenerating the cache on-demand. The cache 
file would be stored in ~/.cache/thunar/<hostname>.mime-cache, and would 
contain a dump of our in-memory database (which will be stored in a 
single memory-chunk as described on the wiki). This would reduce the 
startup time and would avoid the problems of Matthias' idea. But in this 
case Thunar would be responsible for managing the cache, instead of 
having that part in update-mime-database (which made my day when I first 
read Matthias' mail today).

Time to sleep, maybe I'll wake up with a perfect solution. ;-)

>     Jasper

greets,
Benedikt



More information about the Thunar-dev mailing list