[asterisk-commits] mmichelson: branch group/performance r399680 - in /team/group/performance: in...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Sep 24 13:43:33 CDT 2013
Author: mmichelson
Date: Tue Sep 24 13:43:31 2013
New Revision: 399680
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399680
Log:
Cache the string representation of channel nativeformats when nativeformats are set.
Channel snapshot creation was taking quite a bit of time iterating through formats in
order to get the string representation of the formats. Switching to copying formats had
no noticeable positive effect on performance. However, nativeformats are not set on a
channel very often. So if we cache the string representation at that point, then it becomes
trivial to copy this value onto the snapshot when the snapshot is created.
Modified:
team/group/performance/include/asterisk/channel.h
team/group/performance/main/channel_internal_api.c
team/group/performance/main/stasis_channels.c
Modified: team/group/performance/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/performance/include/asterisk/channel.h?view=diff&rev=399680&r1=399679&r2=399680
==============================================================================
--- team/group/performance/include/asterisk/channel.h (original)
+++ team/group/performance/include/asterisk/channel.h Tue Sep 24 13:43:31 2013
@@ -4375,4 +4375,15 @@
*/
void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why);
+/*!
+ * \brief Get the string representation of a channel's native formats
+ *
+ * This will never return NULL. If the channel has no native formats,
+ * then this will return an empty string.
+ *
+ * \param chan Channel to get formats from
+ * \return String representation of channel native formats
+ */
+char *ast_channel_nativeformats_str(struct ast_channel *chan);
+
#endif /* _ASTERISK_CHANNEL_H */
Modified: team/group/performance/main/channel_internal_api.c
URL: http://svnview.digium.com/svn/asterisk/team/group/performance/main/channel_internal_api.c?view=diff&rev=399680&r1=399679&r2=399680
==============================================================================
--- team/group/performance/main/channel_internal_api.c (original)
+++ team/group/performance/main/channel_internal_api.c Tue Sep 24 13:43:31 2013
@@ -208,6 +208,7 @@
struct timeval sending_dtmf_tv; /*!< The time this channel started sending the current digit. (Invalid if sending_dtmf_digit is zero.) */
struct stasis_cp_single *topics; /*!< Topic for all channel's events */
struct stasis_forward *endpoint_forward; /*!< Subscription for event forwarding to endpoint's topic */
+ char nativeformats_str[256]; /*!< String representation of nativeformats */
};
/*! \brief The monotonically increasing integer counter for channel uniqueids */
@@ -1496,3 +1497,8 @@
return 0;
}
+
+char *ast_channel_nativeformats_str(struct ast_channel *chan)
+{
+ return chan->nativeformats_str;
+}
Modified: team/group/performance/main/stasis_channels.c
URL: http://svnview.digium.com/svn/asterisk/team/group/performance/main/stasis_channels.c?view=diff&rev=399680&r1=399679&r2=399680
==============================================================================
--- team/group/performance/main/stasis_channels.c (original)
+++ team/group/performance/main/stasis_channels.c Tue Sep 24 13:43:31 2013
@@ -174,7 +174,6 @@
{
RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
RAII_VAR(struct ast_bridge *, bridge, NULL, ao2_cleanup);
- char nativeformats[256];
struct ast_str *write_transpath = ast_str_alloca(256);
struct ast_str *read_transpath = ast_str_alloca(256);
struct ast_party_id effective_connected_id;
@@ -236,8 +235,7 @@
ast_string_field_set(snapshot, bridgeid, bridge->uniqueid);
}
- ast_string_field_set(snapshot, nativeformats, ast_getformatname_multiple(nativeformats, sizeof(nativeformats),
- ast_channel_nativeformats(chan)));
+ ast_string_field_set(snapshot, nativeformats, ast_channel_nativeformats_str(chan));
ast_string_field_set(snapshot, readformat, ast_getformatname(ast_channel_readformat(chan)));
ast_string_field_set(snapshot, writeformat, ast_getformatname(ast_channel_writeformat(chan)));
ast_string_field_set(snapshot, writetrans, ast_translate_path_to_str(ast_channel_writetrans(chan), &write_transpath));
More information about the asterisk-commits
mailing list