mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Stasis performance improvements
This patch addresses several performance problems that were found in the initial performance testing of Asterisk 12. The Stasis dispatch object was allocated as an AO2 object, even though it has a very confined lifecycle. This was replaced with a straight ast_malloc(). The Stasis message router was spending an inordinate amount of time searching hash tables. In this case, most of our routers had 6 or fewer routes in them to begin with. This was replaced with an array that's searched linearly for the route. We more heavily rely on AO2 objects in Asterisk 12, and the memset() in ao2_ref() actually became noticeable on the profile. This was #ifdef'ed to only run when AO2_DEBUG was enabled. After being misled by an erroneous comment in taskprocessor.c during profiling, the wrong comment was removed. Review: https://reviewboard.asterisk.org/r/2873/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@400138 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -867,52 +867,6 @@ AST_TEST_DEFINE(cache_dump)
|
||||
return AST_TEST_PASS;
|
||||
}
|
||||
|
||||
AST_TEST_DEFINE(route_conflicts)
|
||||
{
|
||||
RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
|
||||
RAII_VAR(struct stasis_message_router *, uut, NULL, stasis_message_router_unsubscribe_and_join);
|
||||
RAII_VAR(struct stasis_message_type *, test_message_type, NULL, ao2_cleanup);
|
||||
RAII_VAR(struct consumer *, consumer1, NULL, ao2_cleanup);
|
||||
RAII_VAR(struct consumer *, consumer2, NULL, ao2_cleanup);
|
||||
int ret;
|
||||
|
||||
switch (cmd) {
|
||||
case TEST_INIT:
|
||||
info->name = __func__;
|
||||
info->category = test_category;
|
||||
info->summary =
|
||||
"Multiple routes to the same message_type should fail";
|
||||
info->description =
|
||||
"Multiple routes to the same message_type should fail";
|
||||
return AST_TEST_NOT_RUN;
|
||||
case TEST_EXECUTE:
|
||||
break;
|
||||
}
|
||||
|
||||
topic = stasis_topic_create("TestTopic");
|
||||
ast_test_validate(test, NULL != topic);
|
||||
|
||||
consumer1 = consumer_create(1);
|
||||
ast_test_validate(test, NULL != consumer1);
|
||||
consumer2 = consumer_create(1);
|
||||
ast_test_validate(test, NULL != consumer2);
|
||||
|
||||
test_message_type = stasis_message_type_create("TestMessage", NULL);
|
||||
ast_test_validate(test, NULL != test_message_type);
|
||||
|
||||
uut = stasis_message_router_create(topic);
|
||||
ast_test_validate(test, NULL != uut);
|
||||
|
||||
ret = stasis_message_router_add(
|
||||
uut, test_message_type, consumer_exec, consumer1);
|
||||
ast_test_validate(test, 0 == ret);
|
||||
ret = stasis_message_router_add(
|
||||
uut, test_message_type, consumer_exec, consumer2);
|
||||
ast_test_validate(test, 0 != ret);
|
||||
|
||||
return AST_TEST_PASS;
|
||||
}
|
||||
|
||||
AST_TEST_DEFINE(router)
|
||||
{
|
||||
RAII_VAR(struct stasis_topic *, topic, NULL, ao2_cleanup);
|
||||
@@ -1373,7 +1327,6 @@ static int unload_module(void)
|
||||
AST_TEST_UNREGISTER(cache_filter);
|
||||
AST_TEST_UNREGISTER(cache);
|
||||
AST_TEST_UNREGISTER(cache_dump);
|
||||
AST_TEST_UNREGISTER(route_conflicts);
|
||||
AST_TEST_UNREGISTER(router);
|
||||
AST_TEST_UNREGISTER(router_cache_updates);
|
||||
AST_TEST_UNREGISTER(interleaving);
|
||||
@@ -1397,7 +1350,6 @@ static int load_module(void)
|
||||
AST_TEST_REGISTER(cache_filter);
|
||||
AST_TEST_REGISTER(cache);
|
||||
AST_TEST_REGISTER(cache_dump);
|
||||
AST_TEST_REGISTER(route_conflicts);
|
||||
AST_TEST_REGISTER(router);
|
||||
AST_TEST_REGISTER(router_cache_updates);
|
||||
AST_TEST_REGISTER(interleaving);
|
||||
|
Reference in New Issue
Block a user