mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-15 08:44:14 +00:00
stasis: Segment channel snapshot to reduce creation cost.
When a channel snapshot was created it used to be done from scratch, copying all data (many strings). This incurs a cost when doing so. This change segments the channel snapshot into different components which can be reused if unchanged from the previous snapshot creation, reducing the cost. In normal cases this results in some pointers being copied with reference count being bumped, some integers being set, and a string or two copied. The other benefit is that it is now possible to determine if a channel snapshot update is redundant and thus stop it before a message is published to stasis. The specific segments in the channel snapshot were split up based on whether they are changed together, how often they are changed, and their general grouping. In practice only 1 (or 0) of the segments actually get changed in normal operation. Invalidation is done by setting a flag on the channel when the segment source is changed, forcing creation of a new segment when the channel snapshot is created. ASTERISK-28119 Change-Id: I5d7ef3df963a88ac47bc187d73c5225c315f8423
This commit is contained in:
@@ -6761,6 +6761,12 @@ static void channel_do_masquerade(struct ast_channel *original, struct ast_chann
|
||||
ast_channel_name(clonechan), ast_channel_state(clonechan),
|
||||
ast_channel_name(original), ast_channel_state(original));
|
||||
|
||||
/* When all is said and done force new snapshot segments so they are
|
||||
* up to date.
|
||||
*/
|
||||
ast_set_flag(ast_channel_snapshot_segment_flags(original), AST_FLAGS_ALL);
|
||||
ast_set_flag(ast_channel_snapshot_segment_flags(clonechan), AST_FLAGS_ALL);
|
||||
|
||||
/*
|
||||
* Remember the original read/write formats. We turn off any
|
||||
* translation on either one
|
||||
@@ -7183,6 +7189,7 @@ void ast_channel_set_caller(struct ast_channel *chan, const struct ast_party_cal
|
||||
|
||||
ast_channel_lock(chan);
|
||||
ast_party_caller_set(ast_channel_caller(chan), caller, update);
|
||||
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER);
|
||||
ast_channel_unlock(chan);
|
||||
}
|
||||
|
||||
@@ -7195,6 +7202,7 @@ void ast_channel_set_caller_event(struct ast_channel *chan, const struct ast_par
|
||||
|
||||
ast_channel_lock(chan);
|
||||
ast_party_caller_set(ast_channel_caller(chan), caller, update);
|
||||
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER);
|
||||
ast_channel_publish_snapshot(chan);
|
||||
ast_channel_unlock(chan);
|
||||
}
|
||||
@@ -8120,6 +8128,7 @@ void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_p
|
||||
|
||||
ast_channel_lock(chan);
|
||||
ast_party_connected_line_set(ast_channel_connected(chan), connected, update);
|
||||
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_CONNECTED);
|
||||
ast_channel_publish_snapshot(chan);
|
||||
ast_channel_unlock(chan);
|
||||
}
|
||||
@@ -8930,6 +8939,7 @@ void ast_channel_set_redirecting(struct ast_channel *chan, const struct ast_part
|
||||
|
||||
ast_channel_lock(chan);
|
||||
ast_party_redirecting_set(ast_channel_redirecting(chan), redirecting, update);
|
||||
ast_channel_snapshot_invalidate_segment(chan, AST_CHANNEL_SNAPSHOT_INVALIDATE_CALLER);
|
||||
ast_channel_unlock(chan);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user