summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2014-06-13 18:24:49 +0000
committerMatthew Jordan <mjordan@digium.com>2014-06-13 18:24:49 +0000
commit9cc1a8e8936760a44def12c30329d6284f4139a8 (patch)
tree00cb0fb5904021052c0b9b6c6bc5c97e008be21f /include
parent0acc6265303822e0c5b4044d8152f38896fdbe83 (diff)
stasis: Reduce creation of channel snapshots to improve performance
During some performance testing of Asterisk with AGI, ARI, and lots of Local channels, we noticed that there's quite a hit in performance during channel creation and releasing to the dialplan (ARI continue). After investigating the performance spike that occurs during channel creation, we discovered that we create a lot of channel snapshots that are technically unnecessary. This includes creating snapshots during: * AGI execution * Returning objects for ARI commands * During some Local channel operations * During some dialling operations * During variable setting * During some bridging operations And more. This patch does the following: - It removes a number of fields from channel snapshots. These fields were rarely used, were expensive to have on the snapshot, and hurt performance. This included formats, translation paths, Log Call ID, callgroup, pickup group, and all channel variables. As a result, AMI Status, "core show channel", "core show channelvar", and "pjsip show channel" were modified to either hit the live channel or not show certain pieces of data. While this is unfortunate, the performance gain from this patch is worth the loss in behaviour. - It adds a mechanism to publish a cached snapshot + blob. A large number of publications were changed to use this, including: - During Dial begin - During Variable assignment (if no AMI variables are emitted - if AMI variables are set, we have to make snapshots when a variable is changed) - During channel pickup - When a channel is put on hold/unhold - When a DTMF digit is begun/ended - When creating a bridge snapshot - When an AOC event is raised - During Local channel optimization/Local bridging - When endpoint snapshots are generated - All AGI events - All ARI responses that return a channel - Events in the AgentPool, MeetMe, and some in Queue - Additionally, some extraneous channel snapshots were being made that were unnecessary. These were removed. - The result of ast_hashtab_hash_string is now cached in stasis_cache. This reduces a large number of calls to ast_hashtab_hash_string, which reduced the amount of time spent in this function in gprof by around 50%. #ASTERISK-23811 #close Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/3568/ ........ Merged revisions 416211 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416216 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/channel.h9
-rw-r--r--include/asterisk/stasis_channels.h39
2 files changed, 31 insertions, 17 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 3575bae8f..505e4bac9 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -4179,6 +4179,15 @@ void ast_channel_dialed_causes_clear(const struct ast_channel *chan);
struct ast_flags *ast_channel_flags(struct ast_channel *chan);
/*!
+ * \since 12.4.0
+ * \brief Return whether or not any manager variables have been set
+ *
+ * \retval 0 if no manager variables are expected
+ * \retval 1 if manager variables are expected
+ */
+int ast_channel_has_manager_vars(void);
+
+/*!
* \since 12
* \brief Sets the variables to be stored in the \a manager_vars field of all
* snapshots.
diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h
index b4097b31b..a252a2a90 100644
--- a/include/asterisk/stasis_channels.h
+++ b/include/asterisk/stasis_channels.h
@@ -39,17 +39,16 @@
struct ast_channel_snapshot {
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(name); /*!< ASCII unique channel name */
- AST_STRING_FIELD(type); /*!< Type of channel technology */
- AST_STRING_FIELD(accountcode); /*!< Account code for billing */
- AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
- AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
AST_STRING_FIELD(uniqueid); /*!< Unique Channel Identifier */
AST_STRING_FIELD(linkedid); /*!< Linked Channel Identifier -- gets propagated by linkage */
- AST_STRING_FIELD(hangupsource); /*!< Who is responsible for hanging up this channel */
AST_STRING_FIELD(appl); /*!< Current application */
AST_STRING_FIELD(data); /*!< Data passed to current application */
AST_STRING_FIELD(context); /*!< Dialplan: Current extension context */
AST_STRING_FIELD(exten); /*!< Dialplan: Current extension number */
+ AST_STRING_FIELD(accountcode); /*!< Account code for billing */
+ AST_STRING_FIELD(peeraccount); /*!< Peer account code for billing */
+ AST_STRING_FIELD(userfield); /*!< Userfield for CEL billing */
+ AST_STRING_FIELD(hangupsource); /*!< Who is responsible for hanging up this channel */
AST_STRING_FIELD(caller_name); /*!< Caller ID Name */
AST_STRING_FIELD(caller_number); /*!< Caller ID Number */
AST_STRING_FIELD(caller_dnid); /*!< Dialed ID Number */
@@ -59,31 +58,20 @@ struct ast_channel_snapshot {
AST_STRING_FIELD(dialed_subaddr); /*!< Dialed subaddress */
AST_STRING_FIELD(connected_name); /*!< Connected Line Name */
AST_STRING_FIELD(connected_number); /*!< Connected Line Number */
- AST_STRING_FIELD(effective_name); /*!< Effective Connected Line Name */
- AST_STRING_FIELD(effective_number); /*!< Effective Connected Line Number */
AST_STRING_FIELD(language); /*!< The default spoken language for the channel */
AST_STRING_FIELD(bridgeid); /*!< Unique Bridge Identifier */
- AST_STRING_FIELD(nativeformats); /*!< Native formats on the channel */
- AST_STRING_FIELD(readformat); /*!< The current read format */
- AST_STRING_FIELD(writeformat); /*!< The current write format */
- AST_STRING_FIELD(writetrans); /*!< The current write translation path */
- AST_STRING_FIELD(readtrans); /*!< The current read translation path */
+ AST_STRING_FIELD(type); /*!< Type of channel technology */
);
- char callid[AST_CALLID_BUFFER_LENGTH]; /*!< Callid for the channel */
struct timeval creationtime; /*!< The time of channel creation */
- struct timeval hanguptime; /*!< When the channel should hang up */
enum ast_channel_state state; /*!< State of line */
int priority; /*!< Dialplan: Current extension priority */
int amaflags; /*!< AMA flags for billing */
int hangupcause; /*!< Why is the channel hanged up. See causes.h */
int caller_pres; /*!< Caller ID presentation. */
struct ast_flags flags; /*!< channel flags of AST_FLAG_ type */
- ast_group_t callgroup; /*!< Call group */
- ast_group_t pickupgroup; /*!< Pickup group */
struct ast_flags softhangup_flags; /*!< softhangup channel flags */
struct varshead *manager_vars; /*!< Variables to be appended to manager events */
- struct varshead *channel_vars; /*!< Variables set on the channel */
int tech_properties; /*!< Properties of the channel's technology */
};
@@ -321,6 +309,23 @@ void ast_channel_publish_blob(struct ast_channel *chan, struct stasis_message_ty
struct ast_json *blob);
/*!
+ * \brief Publish a channel blob message using the latest snapshot from the cache
+ * \since 12.4.0
+ *
+ * \param chan Channel publishing the blob.
+ * \param type Type of stasis message.
+ * \param blob The blob being published. (NULL if no blob)
+ *
+ * \note As this only accesses the uniqueid and topic of the channel - neither of
+ * which should ever be changed on a channel anyhow - a channel does not have to
+ * be locked when calling this function.
+ *
+ * \return Nothing
+ */
+void ast_channel_publish_cached_blob(struct ast_channel *chan, struct stasis_message_type *type,
+ struct ast_json *blob);
+
+/*!
* \since 12
* \brief Set flag to indicate channel snapshot is being staged.
*