Ethereal-dev: Re: [Ethereal-dev] compare_proto_id taking up 20% of Ethereal's time

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Richard Sharpe <rsharpe@xxxxxxxxxxxxxxxxx>
Date: Sun, 16 Nov 2003 13:09:42 -0800 (PST)
On Sun, 16 Nov 2003, Guy Harris wrote:

> On Sat, Nov 15, 2003 at 10:45:20PM -0800, Richard Sharpe wrote:
> > We seem to be doing some silly things ... while it is useful to keep the 
> > protocols in a glist, because we need to iterate over them, I don't see 
> > why we are doing this:
> > 
> >         if (handle->proto_index != -1 &&
> >             !proto_is_protocol_enabled(handle->proto_index)) {
> >                 /*
> >                  * The protocol isn't enabled.
> >                  */
> >                 return 0;
> >         }
> > 
> > proto_index should be a void * that actually points to an instance of a 
> > protocol_t. That way we can, in the epan/proto.c routines, simply 
> > dereference it to get at the fields we need. 
> 
> No, we should replace "proto_index" with a "protocol_t *", and give it a
> name that doesn't contain "index" (as it's a pointer, not an index).
> 
> A null "protocol_t" pointer would be equivalent to -1 as "proto_index". 
> A "protocol_t" contains a protocol index, so
> "dissector_handle_get_protocol_index()" could still work.
> 
> A dissector_handle_t is opaque outside "epan/packet.c", so we don't have
> to worry about dragging in extra include files if we add a "protocol_t
> *" to the dissector handle.  It does, however, require that we export
> "protocol_t" from "epan/proto.c" to "epan/packet.c".

OK, I think I can justify spending some time on this this week, since I am 
looking at performance matters and handling large capture files is one of 
the things I am doing (some as large as 600MB) ... :-(

So, it seems that I have to:

1. Change epan/proto.c and epan/packet.c
2. Change those routines in gtk/*.c that deal with proto_ids
3. Modify every packet_*.c routine that declares '^static int proto_xyz = 
-1'

Regards
-----
Richard Sharpe, rsharpe[at]ns.aus.com, rsharpe[at]samba.org, 
sharpe[at]ethereal.com, http://www.richardsharpe.com