9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Bakul Shah <bakul+plan9@bitblocks.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] a question of file and the history of magic
Date: Sun,  6 Jul 2008 15:31:30 -0700	[thread overview]
Message-ID: <20080706223130.5542B5B46@mail.bitblocks.com> (raw)
In-Reply-To: Your message of "Sun, 06 Jul 2008 17:20:12 EDT." <893336fd0a9673f20c7468d7f6339554@quanstro.net>

On Sun, 06 Jul 2008 17:20:12 EDT erik quanstrom <quanstro@quanstro.net>  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.



  parent reply	other threads:[~2008-07-06 22:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-06 21:20 erik quanstrom
2008-07-06 21:59 ` Brantley Coile
2008-07-09  0:30   ` [9fans] a question of file and the history of magic^H^H^H^H^HUNIX Lyndon Nerenberg
2008-07-06 22:31 ` Bakul Shah [this message]
2008-07-06 22:44   ` [9fans] a question of file and the history of magic Charles Forsyth
  -- strict thread matches above, loose matches on Subject: below --
2008-07-07  8:58 Harri Haataja
2008-07-11 16:21 ` Dan Cross
2008-07-06 23:45 geoff
2008-07-06 19:30 erik quanstrom
2008-07-06 21:00 ` Jeff Sickel
2008-07-06 18:16 Jeff Sickel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080706223130.5542B5B46@mail.bitblocks.com \
    --to=bakul+plan9@bitblocks.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).