diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-29 20:50:36 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-29 20:50:36 +0000 |
commit | 53f8d43e2945038fe3059fd6c1c00dd4ec117505 (patch) | |
tree | 0f3fc04bcb07ac328d54ffb2fed0333dfffb44de /include | |
parent | 562decf81af443d24afd3f1fc3d133b8b2b7cee3 (diff) |
Merge team/russell/frame_caching
There are some situations in Asterisk where ast_frame and/or iax_frame
structures are rapidly allocatted and freed (at least 50 times per second
for one call).
This code significantly improves the performance of ast_frame_header_new(),
ast_frdup(), ast_frfree(), iax_frame_new(), and iax_frame_free() by keeping
a thread-local cache of these structures and using frames from the cache
whenever possible instead of calling malloc/free every time.
This commit also converts the ast_frame and iax_frame structures to use the
linked list macros.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@41278 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/channel.h | 2 | ||||
-rw-r--r-- | include/asterisk/chanspy.h | 2 | ||||
-rw-r--r-- | include/asterisk/frame.h | 9 | ||||
-rw-r--r-- | include/asterisk/slinfactory.h | 2 |
4 files changed, 8 insertions, 7 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index e4c48a993..95cb3196e 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -410,7 +410,7 @@ struct ast_channel { unsigned int pickupgroup; /*!< Pickup group - which calls groups can be picked up? */ unsigned int flags; /*!< channel flags of AST_FLAG_ type */ unsigned short transfercapability; /*!< ISDN Transfer Capbility - AST_FLAG_DIGITAL is not enough */ - struct ast_frame *readq; + AST_LIST_HEAD_NOLOCK(, ast_frame) readq; int alertpipe[2]; int nativeformats; /*!< Kinds of data this channel can natively handle */ diff --git a/include/asterisk/chanspy.h b/include/asterisk/chanspy.h index ee4a10759..dd8d79edf 100644 --- a/include/asterisk/chanspy.h +++ b/include/asterisk/chanspy.h @@ -49,7 +49,7 @@ enum chanspy_flags { }; struct ast_channel_spy_queue { - struct ast_frame *head; + AST_LIST_HEAD_NOLOCK(, ast_frame) list; unsigned int samples; unsigned int format; }; diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h index 35cd30ac6..0c9c651d2 100644 --- a/include/asterisk/frame.h +++ b/include/asterisk/frame.h @@ -32,6 +32,7 @@ extern "C" { #include <sys/types.h> #include <sys/time.h> #include "asterisk/endian.h" +#include "asterisk/linkedlists.h" struct ast_codec_pref { char order[32]; @@ -97,6 +98,8 @@ struct ast_frame { int samples; /*! Was the data malloc'd? i.e. should we free it when we discard the frame? */ int mallocd; + /*! The number of bytes allocated for a malloc'd frame header */ + size_t mallocd_hdr_len; /*! How many bytes exist _before_ "data" that can be used if needed */ int offset; /*! Optional source of frame for debugging */ @@ -105,10 +108,8 @@ struct ast_frame { void *data; /*! Global delivery time */ struct timeval delivery; - /*! Next/Prev for linking stand alone frames */ - struct ast_frame *prev; - /*! Next/Prev for linking stand alone frames */ - struct ast_frame *next; + /*! For placing in a linked list */ + AST_LIST_ENTRY(ast_frame) frame_list; /*! Timing data flag */ int has_timing_info; /*! Timestamp in milliseconds */ diff --git a/include/asterisk/slinfactory.h b/include/asterisk/slinfactory.h index 4bdbfa7cd..b81817d6b 100644 --- a/include/asterisk/slinfactory.h +++ b/include/asterisk/slinfactory.h @@ -32,7 +32,7 @@ extern "C" { #endif struct ast_slinfactory { - struct ast_frame *queue; + AST_LIST_HEAD_NOLOCK(, ast_frame) queue; struct ast_trans_pvt *trans; short hold[1280]; short *offset; |