Ethereal-dev: [Ethereal-dev] Performance discussions...

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

From: Ulf Lamping <ulf.lamping@xxxxxx>
Date: Tue, 11 Jan 2005 23:08:29 +0100
Hi List!

While profiling on win32, I've noticed that a lot of time is spend in the function proto_register_protocol() in file epan/proto.c, at least for debug versions of Ethereal.

This is caused by the three calls to:

   g_assert(g_list_find_custom(protocols, name, proto_match_name) == NULL);
g_assert(g_list_find_custom(protocols, short_name, proto_match_short_name) == NULL); g_assert(g_list_find_custom(protocols, filter_name, proto_match_filter_name) == NULL);

When I experimentally remove this three calls, Ethereal will start half a second faster on my machine :-)

The reason for this is that if a new protocol is added, each of the three lines will go through the whole list of existing protocols (around a maximum of fivehundred) and will do a g_strcasecmp() for each entry in it!


I'm in favour of keeping a hash_table for the proto_name, proto_short_name and proto_filter_name, so something like the following could be used:

xxx_names = g_hash_table_new(g_str_hash, g_str_equal);

This would decrease the amount of time for startup a lot :-)


Any notes on this or an even better idea?

Regards, ULFL

BTW: it's not quite ok to use g_assert() here at all, as adding a new protocol with an already existing name as a plugin might not always be done using a developer version of Ethereal. So in this case Ethereal might crash (however, it will crash reliably I would guess ;-) ---- So doing this test in all versions of Ethereal might be a good idea in any case...