Wireshark-dev: Re: [Wireshark-dev] proto_filter_names hash collision
From: "Kukosa, Tomas" <tomas.kukosa@xxxxxxxxxxx>
Date: Wed, 21 Nov 2007 09:58:05 +0100
> > Does it make sense to do all those sanity checks only if a special 
> > command-line flag is supplied to TShark, so that the checks 
> are done as 
> > part of the build process, rather than being done every 
> time you run 
> > Wireshark or TShark?
> 
> Yes, because you ever know what cocktail of plugins the user 
> has added 
> to its installation.

I think we can leave this sanity check for short and filter names.

The whole proto_register_protocol() function (including hash
computation) takes about 5% of startup time now.
More than 60% of proto_register_protocol() time takes g_str_hash()
computation. I guess most of that time are hashes for long protocol
names.

My proposal is following:
 - leave sanity check of short and filter names but do not hash them as
2-4 string comparision is not much slower than integer comparision and
g_str_hash() is not very god for short strings and it is easy to have
collision
 - remove sanity check for long protocol names as it is not critical to
have this name unique (or perform this check only with some new
command-line option "strict sanity check")

Any comments?