Ticket #4816 (new patch)
Oscar protocol performance improvement(s)
| Reported by: | oliver | Owned by: | MarkDoliner |
|---|---|---|---|
| Milestone: | Patches Needing Review | Component: | AIM |
| Version: | 2.3.1 | Keywords: | oscar performance patch |
| Cc: |
Description
oscar.c:6581 oscar_normalize() does a string copy (line 6589) but the following loop effectively moves each byte (skipping the blanks). I think we can use only the loop to copy the string and remove the (expensive) call to strncpy(). vallgrind/callgrind says that the strncpy() call is responsible for more than half the time spent in this function and of all the liboscar function it is one of the most often called. See attached patch.
Which brings me to the next bottleneck/performance problem.
Lot's of time is spend in aim_sncmp() (util.c 232) because (a) the function is kind of expensive and (b) it's called a lot. I think the big rblem here is that all the aim_ssi_itemlist_* functions are littered with linear searches that call the compare function in the loop (family_feedbag.c:309 and family_feedbag.c:352).[[BR]]
It might be worth to sacrifice a few extra bytes of memory and either (i) store the uppercase&normalized version of the name and keep the linear search or (ii) use a hashmap to lookup the name, effectively getting rid of the linear searches.
This is a bigger change, I'll look into that but comments are welcome.



