]> git.ipfire.org Git - thirdparty/asterisk.git/commit
main/pbx: Improve performance of dialplan reloads with a large number of hints 12/312/6
authorMatt Jordan <mjordan@digium.com>
Wed, 29 Apr 2015 19:49:23 +0000 (14:49 -0500)
committerMatt Jordan <mjordan@digium.com>
Fri, 1 May 2015 13:25:47 +0000 (08:25 -0500)
commit1b19c15f17d7275b7f807e0532b9a5d2ea829aa2
tree512d979302a5cb93f3fc39c79ddbcbb25760f338
parentec0f80b6e8d5f6952bdf48e8f19a024ebc64840e
main/pbx: Improve performance of dialplan reloads with a large number of hints

The PBX core maintains two hash tables for hints: a container of the
actual hints (hints), along with a container of devices that are watching that
hint (hintdevices). When a dialplan reload occurs, each hint in the hints
container is destroyed; this requires a lookup in the container of devices to
find the device => hint mapping object. In the current code, this performs an
ao2_callback, iterating over each of the device to hint objects in the
hintdevices container. For a large number of hints, this is extremely
expensive: dialplan reloads with 20000 hints could take several minutes
in just this phase.

This patch improves the performance of this step in the dialplan reloads
by caching which devices are watching a hint on the hint object itself.
Since we don't want to create a circular reference, we just cache the
name of the device. This allows us to perform a smarter ao2_callback on
the hintdevices container during hint removal, hashing on the name of the
device and returning an iterator to the matching names. The overall
performance improvement is rather large, taking this step down to a number of
seconds as opposed to minutes.

In addition, this patch also registers the hint containers in the PBX
core with the astobj2 library. This allows for reasonable debugging to
hash collisions in those containers.

ASTERISK-25040 #close
Reported by: Matt Jordan

Change-Id: Iedfc97a69d21070c50fca42275d7b3e714e59360
main/pbx.c