Re: new mime detection approach



On Thu, 2004-01-15 at 05:43, Peter Harvey wrote:

> I have no idea how the magic mime-type detection code works, but would
> it be made faster by using the extensions of a file as a hint? ie. if
> you are trying to determine the type of a file with .jpg extension,
> first check the JPEG magic entry? This should only involve reading the
> first few characters of the file.

This doesn't help. The slow part about sniffing is reading the first few
bytes of the file. You have to do several seeks on the hard-drive, and
each seek is delayed by the HD seek time and on average half a
rotational delay. This adds up to about 10-15 msecs per file, and faster
harddrives don't really make this better. In fact, Alan Cox claimed that
opening a new file takes about the same time as reading another 8 meg
from a continuous file (on modern disks). 

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's an oversexed crooked stage actor whom everyone believes is mad. She's a 
hard-bitten antique-collecting archaeologist with her own daytime radio talk 
show. They fight crime! 




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]