]> git.ipfire.org Git - thirdparty/asterisk.git/commit
main/pbx: Improve performance of dialplan reloads with a large number of hints 14/314/5
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:44:25 +0000 (08:44 -0500)
commit8297136fdf52e9697b607d33494c1e0b90ad2090
treeffd9ec34b087d6cdad8822d4bfc2775feebb9cce
parent176cb0d45b70b59a59f942e4170f5dbef3c733e5
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
(cherry picked from commit 80c0756f7386452fddab3324fa6a71933cde006e)
main/pbx.c