From mboxrd@z Thu Jan 1 00:00:00 1970 To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> In-reply-to: Your message of "Sun, 06 Jul 2008 17:20:12 EDT." <893336fd0a9673f20c7468d7f6339554@quanstro.net> From: Bakul Shah Date: Sun, 6 Jul 2008 15:31:30 -0700 Message-Id: <20080706223130.5542B5B46@mail.bitblocks.com> Subject: Re: [9fans] a question of file and the history of magic Topicbox-Message-UUID: dca717c4-ead3-11e9-9d60-3106f5b1d025 On Sun, 06 Jul 2008 17:20:12 EDT erik quanstrom wrote: > what is the upside to an external magic file? as you've shown, you > can add a file type in 1 line of code. while the external magic file > isn't c, i would argue that it's still code. Yes it is code but the advantage is that the parser language is factored out and anyone can add knowledge about new file formats and it is easy to debug and experiment. The main disadvantage of gnu file is performance. As an example, on about 6000 files totalling 200MB, gnu file takes 2s user, 1s system and 30s real time. Compared to that p9p file takes 1.65s user, 0.25s system and 1.9s real time. Note: any cache effects have been accounted for by looking at only the best 3 runs of of each test. As per csh, there were no page faults and no disk io. The magic file should really be compiled and linked w/ file(1) -- if that was done right, the rest of file(1) code would be pretty trivial. On the other hand file is usually not a performance bottleneck. On the gripping hand there are a lot of similarities between cracking file formats and packet formats so may be there is value in factoring all that out and sticking it in a library routine.