Optimize epan_new/init_dissection
authorEvan Huus <eapache@gmail.com>
Mon, 30 Jun 2014 23:46:58 +0000 (19:46 -0400)
committerAnders Broman <a.broman58@gmail.com>
Tue, 1 Jul 2014 04:21:14 +0000 (04:21 +0000)
commita452d16f2c27fc44a41f14d05acca8e94b1c71d8
tree085907efa4a91520b08443bebeead97f201f3764
parent659d0efc928e102d8ca0390a374cddcbad7d8797
Optimize epan_new/init_dissection

As Anders correctly pointed out in I7d8f84b2e, constantly resetting state will
turn init_dissection into a bit of a hot path. Especially as we will already
bear the overhead of switching files, we don't want to fall any further behind
than we have to.

This change includes three unrelated optimizations that reduce the cost of
init_dissection by about 40% as measured by callgrind:
 - only initialize ares/ADNS if that preference is enabled (this of course only
   applies if you specify -n to tshark or otherwise disable the preference)
 - use memcpy instead of a loop in sigcomp UDVM init
 - use memcpy instead of a loop in bootp dissector

The only remaining obvious hot spot in this path is reassembly_table_init since
it is called by so many dissectors. Suggestions (perhaps to get rid of the
GPtrArray) welcome.

Oh, and one other change to use g_strerror instead of strerror as insisted
upon by the API pre-commit hook.

Change-Id: I18a74f2b64b25498116079bd4e7fc2b335c7703a
Reviewed-on: https://code.wireshark.org/review/2738
Reviewed-by: Anders Broman <a.broman58@gmail.com>
epan/addr_resolv.c
epan/dissectors/packet-bootp.c
epan/sigcomp_state_hdlr.c