Ethereal-dev: [Ethereal-dev] Time to look at performance optimizations again?

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

From: Yaniv Kaul <ykaul@xxxxxxxxxxxx>
Date: Sat, 01 Jan 2005 21:41:16 +0200
I'm looking into making Ethereal faster. A great job was done in 0.10.6, if I recall correctly, but I'm still not happy with its performance.

Personally, I see 3 possible vectors to 'attack':
1. GTK is a bit slow on Windows, imho, and Ethereal spends loads of time in it. I'm not going to touch this (donno about GTK enought). 2. Specific dissectors that are slow - I'm not sure it's a real bottleneck. Is anyone aware of a dissectors that's slowing Ethereal down? I'd guess packet-tcp.c, packet-eth.c, packet-ip.c, etc...? 3. Infrastructure and general programming improvement - I'd like to have a go in this direction, in parallel to #2 above.

So far, I've found some places where optimization can take place:
1. Some places where you can replace if(strlen(s) == 0) with something like if(*s='\0').
2. Some strcpy()'s which can be replaced with memcpy()'s.
3. strlen() of const strings (example - lots. One in packet-http.c , in check_auth_ntlmssp()
Strange example from packet-icep.c:
           sprintf(s, "(empty)");
           s[strlen("(empty)")] = '\0';
4. Use of strlen() of a string you just got from get_unicode_or_ascii_string() (example - packet-smb.c, lines 2719 & 2724 and again in 2729) 5. Initializing char arrays by sprintfing to them a const string instead of initializing when defining them.
6. Reordering of switch statements:
In packet-ip.c, capture_ip(), sctp is the first?!
7. Use of signed integers where unsigned could have been better.
Example:  in packet.h,  all counters in packet_counts are defined as gint.
This would have been beneficial if anyone bothered to look for overflow. I didn't see it done (maybe I missed it?).
If it's not done, it's better to used them as unsigned, no?
8. Move stuff from 16bits to 32bits, where possible. I donno if it's possible in ethclist.h, struct _EthCellText, params are defined as gint16.
9. Reordering of structure members.
Example (packet-tds.c):
struct _tds_col {
    gchar name[256];
    guint16 utype;
    guint8 ctype;
    guint csize;
};
should be:
struct _tds_col {
    gchar name[256];
    guint csize;
    guint16 utype;
    guint8 ctype;
};
10. tvb_get_something once, instead of tvb_get_guint8() and another tvb_get_guint8() and another, and another...:
packet-eth.c:
if (    (tvb_get_guint8(tvb, 0) == 0x01 ||
        tvb_get_guint8(tvb, 0) == 0x0C) &&
       tvb_get_guint8(tvb, 1) == 0x00 &&
       tvb_get_guint8(tvb, 2) == 0x0C &&
       tvb_get_guint8(tvb, 3) == 0x00 &&
       tvb_get_guint8(tvb, 4) == 0x00 ) {
     dissect_isl(tvb, pinfo, tree, fcs_len);


Comments are welcome,
Y.