[asterisk-dev] [Code Review] Optimizations to the stringfields API

Russell Bryant russell at digium.com
Wed Feb 18 10:44:17 CST 2009


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviewboard.digium.com/r/165/#review464
-----------------------------------------------------------


I have not looked into this in too much detail.  However, I would really like to see some testing on this (or any other non-trivial patch) before it goes in.

I think it would be a good time to build a test module that uses and abuses the stringfields API.


/trunk/include/asterisk/stringfields.h
<http://reviewboard.digium.com/r/165/#comment1108>

    Why not use a typedef?


- Russell


On 2009-02-18 07:13:53, Kevin Fleming wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.digium.com/r/165/
> -----------------------------------------------------------
> 
> (Updated 2009-02-18 07:13:53)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> This patch provides a number of optimizations to the stringfields API, focused around saving (not wasting) memory whenever possible. Thanks to Mark Michelson for inspiring this work and coming up with the first two optimizations that are represented here:
> 
> Changes:
> 
> - Cleanup of some code, fix incorrect doxygen comments
> 
> - When a field is emptied or replaced with a new allocation, decrease the amount of 'active' space in the pool it was held in; if that pool reaches zero active space, and is not the current pool, then free it as it is no longer in use
> 
> - When allocating a pool, try to allocate a size that will fit in a 'standard' malloc() allocation without wasting space
> 
> - When allocating space for a field, store the amount of space in the two bytes immediately preceding the field; this eliminates the need to call strlen() on the field when overwriting it, and more importantly it 'remembers' the amount of space the field has available, even if a shorter string has been stored in it since it was allocated
> 
> - Don't automatically double the size of each successive pool allocated; it's wasteful
> 
> 
> Diffs
> -----
> 
>   /trunk/include/asterisk/stringfields.h 176937 
>   /trunk/main/utils.c 176937 
> 
> Diff: http://reviewboard.digium.com/r/165/diff
> 
> 
> Testing
> -------
> 
> Compile testing only, so far.
> 
> 
> Thanks,
> 
> Kevin
> 
>




More information about the asterisk-dev mailing list