Summary:ASTERISK-15375: [patch] Optimize queries to cache matches
Reporter:Tilghman Lesher (tilghman)Labels:
Date Opened:2009-12-29 01:11:17.000-0600Date Closed:2010-05-27 14:25:18
Versions:Frequency of
Environment:Attachments:( 0) 20091229__issue16521__1.4.diff.txt
( 1) 20091229__issue16521.diff.txt
Description:A long-running problem of the Realtime Extensions driver has been that it runs the same query 3 times for each extension priority, which is incredibly inefficient.  JR Richardson noted this in a recent post, thinking that it was a bug or a problem on his end.

Hence, I introduce caching for realtime extensions of 1 second, which is more than enough to cut out these extra sets of queries, but not so long as to make the realtime extensions no longer quite realtime.
Comments:By: JR Richardson (hubguru) 2009-12-29 10:00:44.000-0600

Thanks Tilghman, I should be able to test sometime today and report back.


By: JR Richardson (hubguru) 2009-12-29 10:15:25.000-0600

patching file pbx/pbx_realtime.c
Hunk #1 succeeded at 33 with fuzz 2 (offset 6 lines).
Hunk #2 FAILED at 55.
Hunk #3 succeeded at 65 with fuzz 2.
Hunk #4 FAILED at 215.
Hunk ASTERISK-1 FAILED at 237.
Hunk ASTERISK-2 FAILED at 396.
4 out of 6 hunks FAILED -- saving rejects to file pbx/pbx_realtime.c.rej

I'm patching against 1.4.28 stable release.  Did you create this patch against trunk?

By: Tilghman Lesher (tilghman) 2009-12-29 10:20:43.000-0600

Yes, indeed, this is against trunk.  Since this is considered an optimization, not a bugfix, it is not a candidate for inclusion in released versions.

By: JR Richardson (hubguru) 2009-12-29 10:25:46.000-0600

Can I apply the patch to trunk and copy the patched file over to my 1.4.28 release? Will that work or do I need to install trunk and test that?

By: Ronald Chan (loloski) 2009-12-29 10:31:47.000-0600


you can't do that because, the patch in question applies only to trunk

By: Tilghman Lesher (tilghman) 2009-12-29 10:33:38.000-0600

Eh, I just made a patch for 1.4.  It won't go in, but it should work the same.

By: JR Richardson (hubguru) 2009-12-29 11:31:44.000-0600


Saying I’m a bit excited right now is an understatement.  First of all, the patch seems to work fine applied to 1.4.28 stable release.  The performance of this patch is extraordinary.  Before migrating my static dialplan to the database I could push 380 calls at 15 to 20 CPS.  After migrating to the database, I could only push a little more than 100 calls and no more than 6 to 9 CPS.  With this patch applied, I am pushing reliably 300 calls at 15 CPS. 7500+ calls without a hiccup.  Not quite as good as a static dialplan, but that is expected.  MySQLd has also decreased utilization, as expected, from 6 to 12, now 1 to 6.  This has got to be an overall performance increase by 50% or more.

I will be patching on my new 1.4 systems going forward.  The sooner this patch gets applied to Asterisk, the better.



By: Ronald Chan (loloski) 2009-12-29 11:47:30.000-0600


I stand corrected, if this really good, then i will applied this as well to one of my 1.4 production server.


By: Digium Subversion (svnbot) 2010-05-27 14:25:16

Repository: asterisk
Revision: 266238

U   trunk/CHANGES
U   trunk/pbx/pbx_realtime.c

r266238 | tilghman | 2010-05-27 14:25:16 -0500 (Thu, 27 May 2010) | 11 lines

Cache query results for one second.

Queries from the PBX core come in 3's.  Caching avoids the additional
performance penalty from those two additional queries hitting the database.

(closes issue ASTERISK-15375)
Reported by: tilghman
      20091229__issue16521.diff.txt uploaded by tilghman (license 14)
Tested by: Hubguru, tilghman