[asterisk-commits] russell: branch russell/frame_caching r41234 - in
/team/russell/frame_caching...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Aug 28 10:21:42 MST 2006
Author: russell
Date: Mon Aug 28 12:21:42 2006
New Revision: 41234
URL: http://svn.digium.com/view/asterisk?rev=41234&view=rev
Log:
remove stuff i was using to gather statistics
Modified:
team/russell/frame_caching/channels/chan_iax2.c
team/russell/frame_caching/channels/iax2-parser.c
team/russell/frame_caching/main/asterisk.c
team/russell/frame_caching/main/frame.c
Modified: team/russell/frame_caching/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/channels/chan_iax2.c?rev=41234&r1=41233&r2=41234&view=diff
==============================================================================
--- team/russell/frame_caching/channels/chan_iax2.c (original)
+++ team/russell/frame_caching/channels/chan_iax2.c Mon Aug 28 12:21:42 2006
@@ -2088,15 +2088,6 @@
ast_cli(fd, "Outstanding frames: %d (%d ingress, %d egress)\n", iax_get_frames(), iax_get_iframes(), iax_get_oframes());
ast_cli(fd, "Packets in transmit queue: %d dead, %d final, %d total\n\n", dead, final, cnt);
- ast_cli(fd, " IAX Frame Cache Statistics\n"
- "---------------------------------------\n"
- "Added to Cache: %d\n"
- "Removed from Cache: %d\n"
- "Frames Allocated: %d\n"
- "Frames Freed %d\n\n",
- iax_get_added_to_cache(), iax_get_removed_from_cache(),
- iax_get_frames_allocated(), iax_get_frames_freed());
-
return RESULT_SUCCESS;
}
Modified: team/russell/frame_caching/channels/iax2-parser.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/channels/iax2-parser.c?rev=41234&r1=41233&r2=41234&view=diff
==============================================================================
--- team/russell/frame_caching/channels/iax2-parser.c (original)
+++ team/russell/frame_caching/channels/iax2-parser.c Mon Aug 28 12:21:42 2006
@@ -50,17 +50,6 @@
static int iframes = 0;
static int oframes = 0;
-static unsigned int added_to_cache = 0;
-static unsigned int removed_from_cache = 0;
-static unsigned int frames_allocated = 0;
-static unsigned int frames_freed = 0;
-
-#define ENABLE_FRAME_CACHING
-
-static int iax_frame_new_profile = -1;
-static int iax_frame_free_profile = -1;
-
-#ifdef ENABLE_FRAME_CACHING
static void frame_cache_cleanup(void *data);
/*! \brief A per-thread cache of iax_frame structures */
@@ -69,7 +58,6 @@
/*! \brief This is just so iax_frames, a list head struct for holding a list of
* iax_frame structures, is defined. */
AST_LIST_HEAD_NOLOCK(iax_frames, iax_frame);
-#endif
static void internaloutput(const char *str)
{
@@ -612,8 +600,6 @@
void iax_set_error(void (*func)(const char *))
{
- iax_frame_new_profile = ast_add_profile("iax_frame_new_profile", 0);
- iax_frame_free_profile = ast_add_profile("iax_frame_free_profile", 0);
errorf = func;
}
@@ -951,13 +937,8 @@
struct iax_frame *iax_frame_new(int direction, int datalen)
{
struct iax_frame *fr = NULL;
-#ifdef ENABLE_FRAME_CACHING
struct iax_frames *iax_frames;
-#endif
-
- ast_mark(iax_frame_new_profile, 1);
-
-#ifdef ENABLE_FRAME_CACHING
+
/* Attempt to get a frame from this thread's cache */
if ((iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) {
AST_LIST_TRAVERSE_SAFE_BEGIN(iax_frames, fr, list) {
@@ -966,7 +947,6 @@
AST_LIST_REMOVE_CURRENT(iax_frames, list);
memset(fr, 0, sizeof(*fr));
fr->mallocd_datalen = mallocd_datalen;
- ast_atomic_fetchadd_int((int *) &removed_from_cache, 1);
break;
}
}
@@ -974,23 +954,14 @@
}
if (!fr) {
-#endif
- if (!(fr = ast_calloc(1, sizeof(*fr) + datalen))) {
- ast_mark(iax_frame_new_profile, 0);
+ if (!(fr = ast_calloc(1, sizeof(*fr) + datalen)))
return NULL;
- }
- ast_atomic_fetchadd_int((int *) &frames_allocated, 1);
fr->mallocd_datalen = datalen;
-#ifdef ENABLE_FRAME_CACHING
- }
-#endif
-
- ast_mark(iax_frame_new_profile, 0);
-
+ }
+
fr->direction = direction;
fr->retrans = -1;
- ast_atomic_fetchadd_int(&frames, 1);
if (fr->direction == DIRECTION_INGRESS)
ast_atomic_fetchadd_int(&iframes, 1);
else
@@ -1001,9 +972,7 @@
static void __iax_frame_free(struct iax_frame *fr, int cache)
{
-#ifdef ENABLE_FRAME_CACHING
struct iax_frames *iax_frames;
-#endif
/* Note: does not remove from scheduler! */
if (fr->direction == DIRECTION_INGRESS)
@@ -1016,45 +985,29 @@
}
fr->direction = 0;
ast_atomic_fetchadd_int(&frames, -1);
- if (cache)
- ast_mark(iax_frame_free_profile, 1);
-#ifdef ENABLE_FRAME_CACHING
if (!cache) {
-#endif
free(fr);
- ast_atomic_fetchadd_int((int *) &frames_freed, 1);
- ast_mark(iax_frame_free_profile, 0);
return;
-#ifdef ENABLE_FRAME_CACHING
}
if (!(iax_frames = ast_threadstorage_get(&frame_cache, sizeof(*iax_frames)))) {
free(fr);
- ast_mark(iax_frame_free_profile, 0);
- ast_atomic_fetchadd_int((int *) &frames_freed, 1);
return;
}
AST_LIST_INSERT_HEAD(iax_frames, fr, list);
- ast_mark(iax_frame_free_profile, 0);
- ast_atomic_fetchadd_int((int *) &added_to_cache, 1);
-#endif
-}
-
-#ifdef ENABLE_FRAME_CACHING
+}
+
static void frame_cache_cleanup(void *data)
{
struct iax_frames *frames = data;
struct iax_frame *cur;
- while ((cur = AST_LIST_REMOVE_HEAD(frames, list))) {
+ while ((cur = AST_LIST_REMOVE_HEAD(frames, list)))
__iax_frame_free(cur, 0);
- ast_atomic_fetchadd_int((int *) &frames_freed, 1);
- }
free(frames);
}
-#endif
void iax_frame_free(struct iax_frame *fr)
{
@@ -1064,9 +1017,3 @@
int iax_get_frames(void) { return frames; }
int iax_get_iframes(void) { return iframes; }
int iax_get_oframes(void) { return oframes; }
-
-unsigned int iax_get_added_to_cache(void) { return added_to_cache; }
-unsigned int iax_get_removed_from_cache(void) { return removed_from_cache; }
-unsigned int iax_get_frames_allocated(void) { return frames_allocated; }
-unsigned int iax_get_frames_freed(void) { return frames_freed; }
-
Modified: team/russell/frame_caching/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/main/asterisk.c?rev=41234&r1=41233&r2=41234&view=diff
==============================================================================
--- team/russell/frame_caching/main/asterisk.c (original)
+++ team/russell/frame_caching/main/asterisk.c Mon Aug 28 12:21:42 2006
@@ -347,7 +347,6 @@
int64_t mark;
int64_t value;
int64_t events;
- ast_mutex_t lock;
};
struct profile_data {
@@ -367,24 +366,18 @@
int n = 10; /* default entries */
if (prof_data == NULL) {
- int x;
prof_data = ast_calloc(1, l + n*sizeof(struct profile_entry));
if (prof_data == NULL)
return -1;
prof_data->entries = 0;
prof_data->max_size = n;
- for (x = 0; x < n; x++)
- ast_mutex_init(&prof_data->e[n].lock);
}
if (prof_data->entries >= prof_data->max_size) {
void *p;
- int x;
n = prof_data->max_size + 20;
p = ast_realloc(prof_data, l + n*sizeof(struct profile_entry));
if (p == NULL)
return -1;
- for (x = prof_data->max_size; x < n; x++)
- ast_mutex_init(&prof_data->e[n].lock);
prof_data = p;
prof_data->max_size = n;
}
@@ -433,7 +426,6 @@
{
if (!prof_data || i < 0 || i > prof_data->entries) /* invalid index */
return 0;
- ast_mutex_lock(&prof_data->e[i].lock);
if (startstop == 1)
prof_data->e[i].mark = rdtsc();
else {
@@ -443,7 +435,6 @@
prof_data->e[i].value += prof_data->e[i].mark;
prof_data->e[i].events++;
}
- ast_mutex_unlock(&prof_data->e[i].lock);
return prof_data->e[i].mark;
}
Modified: team/russell/frame_caching/main/frame.c
URL: http://svn.digium.com/view/asterisk/team/russell/frame_caching/main/frame.c?rev=41234&r1=41233&r2=41234&view=diff
==============================================================================
--- team/russell/frame_caching/main/frame.c (original)
+++ team/russell/frame_caching/main/frame.c Mon Aug 28 12:21:42 2006
@@ -49,27 +49,6 @@
static AST_LIST_HEAD_STATIC(headerlist, ast_frame);
#endif
-static unsigned int mallocd_header_data_src = 0;
-static unsigned int mallocd_header_data = 0;
-static unsigned int mallocd_header_src = 0;
-static unsigned int mallocd_data_src = 0;
-static unsigned int mallocd_header = 0;
-static unsigned int mallocd_data = 0;
-static unsigned int mallocd_src = 0;
-static unsigned int mallocd_none = 0;
-
-static unsigned int added_to_cache = 0;
-static unsigned int removed_from_cache = 0;
-static unsigned int headers_allocated = 0;
-static unsigned int headers_freed = 0;
-
-static int frame_alloc_profile = -1;
-static int frame_free_profile = -1;
-static int frame_dup_profile = -1;
-
-#define ENABLE_FRAME_CACHING
-
-#ifdef ENABLE_FRAME_CACHING
static void frame_cache_cleanup(void *data);
/*! \brief A per-thread cache of frame headers */
@@ -94,7 +73,6 @@
struct ast_frames list;
size_t size;
};
-#endif
#define SMOOTHER_SIZE 8000
@@ -301,12 +279,8 @@
static struct ast_frame *ast_frame_header_new(void)
{
struct ast_frame *f;
-#ifdef ENABLE_FRAME_CACHING
struct ast_frame_cache *frames;
-#endif
-
- ast_mark(frame_alloc_profile, 1);
-#ifdef ENABLE_FRAME_CACHING
+
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
if ((f = AST_LIST_REMOVE_HEAD(&frames->list, frame_list))) {
size_t mallocd_len = f->mallocd_hdr_len;
@@ -314,17 +288,12 @@
f->mallocd_hdr_len = mallocd_len;
f->mallocd = AST_MALLOCD_HDR;
frames->size--;
- ast_mark(frame_alloc_profile, 0);
- ast_atomic_fetchadd_int((int *) &removed_from_cache, 1);
return f;
}
}
-#endif
-
- if (!(f = ast_calloc(1, sizeof(*f)))) {
- ast_mark(frame_alloc_profile, 0);
+
+ if (!(f = ast_calloc(1, sizeof(*f))))
return NULL;
- }
f->mallocd_hdr_len = sizeof(*f);
#ifdef TRACE_FRAMES
@@ -334,62 +303,25 @@
AST_LIST_UNLOCK(&headerlist);
#endif
- ast_mark(frame_alloc_profile, 0);
- ast_atomic_fetchadd_int((int *) &headers_allocated, 1);
return f;
}
-#ifdef ENABLE_FRAME_CACHING
static void frame_cache_cleanup(void *data)
{
struct ast_frame_cache *frames = data;
struct ast_frame *f;
- while ((f = AST_LIST_REMOVE_HEAD(&frames->list, frame_list))) {
+ while ((f = AST_LIST_REMOVE_HEAD(&frames->list, frame_list)))
free(f);
- ast_atomic_fetchadd_int((int *) &headers_freed, 1);
- }
free(frames);
}
-#endif
void ast_frfree(struct ast_frame *fr)
{
- switch (fr->mallocd) {
- case AST_MALLOCD_HDR | AST_MALLOCD_DATA | AST_MALLOCD_SRC:
- ast_atomic_fetchadd_int((int *) &mallocd_header_data_src, 1);
- break;
- case AST_MALLOCD_HDR | AST_MALLOCD_DATA:
- ast_atomic_fetchadd_int((int *) &mallocd_header_data, 1);
- break;
- case AST_MALLOCD_HDR | AST_MALLOCD_SRC:
- ast_atomic_fetchadd_int((int *) &mallocd_header_src, 1);
- break;
- case AST_MALLOCD_DATA | AST_MALLOCD_SRC:
- ast_atomic_fetchadd_int((int *) &mallocd_data_src, 1);
- break;
- case AST_MALLOCD_HDR:
- ast_atomic_fetchadd_int((int *) &mallocd_header, 1);
- break;
- case AST_MALLOCD_DATA:
- ast_atomic_fetchadd_int((int *) &mallocd_data, 1);
- break;
- case AST_MALLOCD_SRC:
- ast_atomic_fetchadd_int((int *) &mallocd_src, 1);
- break;
- case 0:
- ast_atomic_fetchadd_int((int *) &mallocd_none, 1);
- break;
- default:
- ast_log(LOG_ERROR, "Totally bogus frame malloc'd value of '%d'!\n", fr->mallocd);
- }
-
if (!fr->mallocd)
return;
- ast_mark(frame_free_profile, 1);
-#ifdef ENABLE_FRAME_CACHING
if (fr->mallocd == AST_MALLOCD_HDR) {
/* Cool, only the header is malloc'd, let's just cache those for now
* to keep things simple... */
@@ -399,12 +331,10 @@
&& frames->size < FRAME_CACHE_MAX_SIZE) {
AST_LIST_INSERT_HEAD(&frames->list, fr, frame_list);
frames->size++;
- ast_mark(frame_free_profile, 0);
- ast_atomic_fetchadd_int((int *) &added_to_cache, 1);
return;
}
}
-#endif
+
if (fr->mallocd & AST_MALLOCD_DATA) {
if (fr->data)
free(fr->data - fr->offset);
@@ -421,10 +351,7 @@
AST_LIST_UNLOCK(&headerlist);
#endif
free(fr);
- ast_atomic_fetchadd_int((int *) &headers_freed, 1);
- }
-
- ast_mark(frame_free_profile, 0);
+ }
}
/*!
@@ -490,9 +417,7 @@
struct ast_frame *ast_frdup(const struct ast_frame *f)
{
-#ifdef ENABLE_FRAME_CACHING
struct ast_frame_cache *frames;
-#endif
struct ast_frame *out;
int len, srclen = 0;
void *buf = NULL;
@@ -509,9 +434,6 @@
if (srclen > 0)
len += srclen + 1;
- ast_mark(frame_dup_profile, 1);
-
-#ifdef ENABLE_FRAME_CACHING
if ((frames = ast_threadstorage_get(&frame_cache, sizeof(*frames)))) {
AST_LIST_TRAVERSE_SAFE_BEGIN(&frames->list, out, frame_list) {
if (out->mallocd_hdr_len >= len) {
@@ -521,25 +443,17 @@
out->mallocd_hdr_len = mallocd_len;
buf = out;
frames->size--;
- ast_atomic_fetchadd_int((int *) &removed_from_cache, 1);
break;
}
}
AST_LIST_TRAVERSE_SAFE_END
}
if (!buf) {
-#endif
- if (!(buf = ast_calloc(1, len))) {
- ast_mark(frame_dup_profile, 0);
+ if (!(buf = ast_calloc(1, len)))
return NULL;
- }
- ast_atomic_fetchadd_int((int *) &headers_allocated, 1);
out = buf;
out->mallocd_hdr_len = len;
-#ifdef ENABLE_FRAME_CACHING
- }
-#endif
- ast_mark(frame_dup_profile, 0);
+ }
out->frametype = f->frametype;
out->subclass = f->subclass;
@@ -1039,40 +953,6 @@
" Displays debugging statistics from framer\n";
#endif
-static int show_framecache_stats(int fd, int argc, char *argv[])
-{
- if (argc != 3)
- return RESULT_SHOWUSAGE;
-
- ast_cli(fd, "Current ast_free() malloc'd frame component statistics:\n"
- "------------------------------------------------------------\n"
- "header & data & src: %d\n"
- "header & data: %d\n"
- "header & src: %d\n"
- "data & src: %d\n"
- "header: %d\n"
- "data: %d\n"
- "src: %d\n"
- "none: %d\n\n",
- mallocd_header_data_src, mallocd_header_data, mallocd_header_src,
- mallocd_data_src, mallocd_header, mallocd_data, mallocd_src, mallocd_none);
-
- ast_cli(fd, "Frame cache statistics\n"
- "------------------------------------------------------------\n"
- "Added to cache: %d\n"
- "Removed from cache: %d\n"
- "Headers Allocated: %d\n"
- "Headers Freed: %d\n\n",
- added_to_cache, removed_from_cache,
- headers_allocated, headers_freed);
-
- return RESULT_SUCCESS;
-}
-
-static char framecache_stats_usage[] =
-"Usage: show framecache stats\n"
-" Display statistics related to the frame header cache.\n";
-
/* Builtin Asterisk CLI-commands for debugging */
static struct ast_cli_entry my_clis[] = {
{ { "show", "codecs", NULL }, show_codecs, "Shows codecs", frame_show_codecs_usage },
@@ -1083,16 +963,12 @@
#ifdef TRACE_FRAMES
{ { "show", "frame", "stats", NULL }, show_frame_stats, "Shows frame statistics", frame_stats_usage },
#endif
-{ { "show", "framecache", "stats", NULL }, show_framecache_stats, "Show ast_framecache stats", framecache_stats_usage },
};
int init_framer(void)
{
ast_cli_register_multiple(my_clis, sizeof(my_clis)/sizeof(my_clis[0]) );
- frame_alloc_profile = ast_add_profile("frame_alloc_profile", 0);
- frame_free_profile = ast_add_profile("frame_free_profile", 0);
- frame_dup_profile = ast_add_profile("frame_dup_profile", 0);
return 0;
}
More information about the asterisk-commits
mailing list