[asterisk-dev] [Code Review] Convert pbx_spool to use string fields
Mark Michelson
mmichelson at digium.com
Sun Mar 1 16:58:44 CST 2009
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.digium.com/r/168/
-----------------------------------------------------------
(Updated 2009-03-01 16:58:44.299938)
Review request for Asterisk Developers.
Changes
-------
Fix a logic error in init_outgoing. A zero returned from ast_string_field_init means success, not failure.
I ran some tests with this, first to make sure that call files were still working as expected, and then to see about the memory difference. I tried the following simple call files for accuracy:
Channel: Local/037 at internal
Application: Wait
Data: 10000
Callerid: "Mark C Michelson" <1234567890>
Account: GHY329201SHK390
Local/037 at internal answers and waits for 5000 seconds. The other call file I tested for accuracy was the following:
Channel: SIP/2001
Extension: 2000
Context: internal
Priority: 1
Callerid: "Mark C Michelson" <1234567890>
Account: GH2389SKDI321
Extension 2000 at internal dials SIP/2000. Both worked as expected when moved to the outgoing spool directory. I reran the first test with malloc debug enabled and found the following allocations without my patch applied:
2024 bytes allocated in pbx_spool.c
337804 bytes allocated in utils.c
With my patch applied, the allocations changed as such:
168 bytes allocated in pbx_spool.c
337940 bytes allocated in utils.c
Without my patch applied, the allocations in utils.c can all be attributed to other goings-on in Asterisk. So the total number of bytes used to process the call file was 2024. With my patch applied, we have both the allocation in pbx_spool.c plus the allocation for the string field pool(s) inside utils.c. With my patch applied, the total number of bytes allocated for call file processing was 168 + (337940 - 337804) = 314 bytes, a reduction of ~84.5%.
While such savings probably won't be noticed by those who run just a few call files, it will be welcome for those who run hundreds or even thousands of call files at once.
Summary
-------
Simple. Convert all the static buffers used in pbx_spool to be string fields. This will dramatically lower the amount of memory used when processing a call file.
Diffs (updated)
-----
/trunk/pbx/pbx_spool.c 179218
Diff: http://reviewboard.digium.com/r/168/diff
Testing
-------
It compiles.
Thanks,
Mark
More information about the asterisk-dev
mailing list