Permalink
Browse files

[Performance] Reworked how all log calls are made in the source, see …

…changelog.txt for more details
  • Loading branch information...
Akkadius committed Apr 1, 2017
1 parent 93a6efa commit 7aa1d243b0483ad9041537aada44f923bf923390
Showing with 3,126 additions and 3,066 deletions.
  1. +17 −0 changelog.txt
  2. +17 −17 client_files/export/main.cpp
  3. +19 −19 client_files/import/main.cpp
  4. +22 −22 common/crash.cpp
  5. +16 −16 common/database.cpp
  6. +9 −7 common/dbcore.cpp
  7. +118 −118 common/eq_stream.cpp
  8. +10 −10 common/eq_stream_ident.cpp
  9. +103 −97 common/eqemu_logsys.h
  10. +43 −43 common/guild_base.cpp
  11. +1 −1 common/inventory_profile.cpp
  12. +1 −1 common/misc_functions.h
  13. +18 −18 common/patches/rof.cpp
  14. +28 −28 common/patches/rof2.cpp
  15. +11 −11 common/patches/sod.cpp
  16. +11 −11 common/patches/sof.cpp
  17. +4 −4 common/patches/ss_define.h
  18. +11 −11 common/patches/titanium.cpp
  19. +11 −11 common/patches/uf.cpp
  20. +7 −7 common/ptimer.cpp
  21. +15 −15 common/rulesys.cpp
  22. +3 −3 common/say_link.cpp
  23. +32 −32 common/shareddb.cpp
  24. +1 −1 common/spdat.cpp
  25. +2 −2 common/struct_strategy.cpp
  26. +2 −2 common/tcp_connection.cpp
  27. +2 −2 common/tcp_server.cpp
  28. +3 −3 common/timeoutmgr.cpp
  29. +2 −2 common/worldconn.cpp
  30. +12 −12 eqlaunch/eqlaunch.cpp
  31. +9 −9 eqlaunch/worldserver.cpp
  32. +23 −23 eqlaunch/zone_launch.cpp
  33. +23 −23 loginserver/client.cpp
  34. +13 −13 loginserver/client_manager.cpp
  35. +5 −5 loginserver/config.cpp
  36. +17 −17 loginserver/database_mysql.cpp
  37. +6 −6 loginserver/database_postgresql.cpp
  38. +5 −5 loginserver/encryption.cpp
  39. +33 −33 loginserver/main.cpp
  40. +8 −8 loginserver/server_manager.cpp
  41. +44 −44 loginserver/world_server.cpp
  42. +32 −32 queryserv/database.cpp
  43. +11 −11 queryserv/queryserv.cpp
  44. +3 −3 queryserv/worldserver.cpp
  45. +24 −24 shared_memory/main.cpp
  46. +16 −16 ucs/chatchannel.cpp
  47. +41 −40 ucs/clientlist.cpp
  48. +38 −37 ucs/database.cpp
  49. +16 −16 ucs/ucs.cpp
  50. +4 −4 ucs/worldserver.cpp
  51. +88 −86 world/client.cpp
  52. +1 −1 world/cliententry.cpp
  53. +17 −17 world/clientlist.cpp
  54. +12 −12 world/console.cpp
  55. +6 −5 world/eql_config.cpp
  56. +1 −1 world/eqw.cpp
  57. +7 −7 world/eqw_http_handler.cpp
  58. +7 −5 world/eqw_parser.cpp
  59. +12 −12 world/launcher_link.cpp
  60. +5 −5 world/launcher_list.cpp
  61. +16 −16 world/login_server.cpp
  62. +1 −1 world/login_server_list.cpp
  63. +71 −69 world/net.cpp
  64. +6 −6 world/queryserv.cpp
  65. +6 −6 world/ucs.cpp
  66. +13 −13 world/wguild_mgr.cpp
  67. +5 −5 world/worlddb.cpp
  68. +4 −4 world/zonelist.cpp
  69. +53 −53 world/zoneserver.cpp
  70. +19 −19 zone/aa.cpp
  71. +13 −13 zone/aggro.cpp
  72. +71 −71 zone/attack.cpp
  73. +2 −2 zone/bonuses.cpp
  74. +42 −42 zone/bot.cpp
  75. +18 −18 zone/bot_command.cpp
  76. +4 −4 zone/bot_database.cpp
  77. +5 −5 zone/botspellsai.cpp
  78. +31 −31 zone/client.cpp
  79. +6 −6 zone/client_mods.cpp
  80. +314 −311 zone/client_packet.cpp
  81. +18 −18 zone/client_process.cpp
  82. +44 −44 zone/command.cpp
  83. +4 −4 zone/corpse.cpp
  84. +9 −9 zone/doors.cpp
  85. +1 −1 zone/effects.cpp
  86. +1 −1 zone/embparser.cpp
  87. +4 −4 zone/embparser_api.cpp
  88. +5 −5 zone/embperl.cpp
  89. +3 −3 zone/embxs.cpp
  90. +12 −12 zone/entity.cpp
  91. +4 −4 zone/exp.cpp
  92. +2 −2 zone/fearpath.cpp
  93. +2 −2 zone/forage.cpp
  94. +18 −18 zone/groups.cpp
  95. +8 −8 zone/guild.cpp
  96. +17 −17 zone/guild_mgr.cpp
  97. +25 −25 zone/heal_rotation.cpp
  98. +2 −2 zone/horse.cpp
  99. +107 −107 zone/inventory.cpp
  100. +1 −1 zone/loottables.cpp
  101. +2 −2 zone/lua_general.cpp
  102. +23 −23 zone/map.cpp
  103. +53 −53 zone/merc.cpp
  104. +3 −3 zone/mob.cpp
  105. +16 −16 zone/mob_ai.cpp
  106. +67 −65 zone/net.cpp
  107. +3 −3 zone/npc.cpp
  108. +5 −5 zone/object.cpp
  109. +73 −73 zone/pathing.cpp
  110. +24 −16 zone/perl_client.cpp
  111. +1 −1 zone/petitions.cpp
  112. +4 −4 zone/pets.cpp
  113. +1 −1 zone/quest_parser_collection.cpp
  114. +19 −19 zone/questmgr.cpp
  115. +11 −11 zone/raids.cpp
  116. +70 −68 zone/spawn2.cpp
  117. +4 −4 zone/spawngroup.cpp
  118. +31 −29 zone/special_attacks.cpp
  119. +15 −15 zone/spell_effects.cpp
  120. +178 −178 zone/spells.cpp
  121. +130 −126 zone/tasks.cpp
  122. +1 −1 zone/titles.cpp
  123. +33 −33 zone/tradeskills.cpp
  124. +62 −62 zone/trading.cpp
  125. +3 −3 zone/tribute.cpp
  126. +34 −34 zone/waypoints.cpp
  127. +40 −38 zone/worldserver.cpp
  128. +78 −75 zone/zone.cpp
  129. +3 −3 zone/zone.h
  130. +51 −51 zone/zonedb.cpp
  131. +23 −23 zone/zoning.cpp
View
@@ -1,5 +1,22 @@
EQEMu Changelog (Started on Sept 24, 2003 15:50)
-------------------------------------------------------
== 4/1/2017 ==
Akkadius: [Performance] Reworked how all log calls are made in the source
- Before we used Log.Out, we will now use a macro Log(
- Before: Log.Out(Logs::General, Logs::Status, "Importing Spells...");
- After: Log(Logs::General, Logs::Status, "Importing Spells...");
- The difference is
1) It's 200-300x faster especially when log statements are inside very hot code paths. We already
had most hot paths checked before we logged them, but this blankets all existing logging calls now and not just the
select few we had picked out in the source.
2) Strings don't get copied to the stack, popped and pushed constantly even when we hit a log statement that
actually isn't going to log anything.
- We do an 'if (LogSys.log_settings[log_category].is_category_enabled == 1)' before we call a log function
in the log macro so the log function doesn't get called at all if we're not logging the category
- This has increased binary executables roughly 15KB
- The old extern for EQEmuLogSys is now named LogSys appropriately instead of Log (Ex: LogSys.StartFileLogs())
- The result keeps logging footprint non-existent for when we're not logging that category
== 03/30/2017 ==
Akkadius: [Performance] Fixed an overhead issue where many hot paths would trigger quest subroutines and beneath that the code would
try to see if a quest existed perpetually (checking if file exists) even though it should have determined the quest
@@ -27,7 +27,7 @@
#include "../../common/rulesys.h"
#include "../../common/string_util.h"
EQEmuLogSys Log;
EQEmuLogSys LogSys;
void ExportSpells(SharedDatabase *db);
void ExportSkillCaps(SharedDatabase *db);
@@ -36,46 +36,46 @@ void ExportDBStrings(SharedDatabase *db);
int main(int argc, char **argv) {
RegisterExecutablePlatform(ExePlatformClientExport);
Log.LoadLogSettingsDefaults();
LogSys.LoadLogSettingsDefaults();
set_exception_handler();
Log.Out(Logs::General, Logs::Status, "Client Files Export Utility");
Log(Logs::General, Logs::Status, "Client Files Export Utility");
if(!EQEmuConfig::LoadConfig()) {
Log.Out(Logs::General, Logs::Error, "Unable to load configuration file.");
Log(Logs::General, Logs::Error, "Unable to load configuration file.");
return 1;
}
auto Config = EQEmuConfig::get();
SharedDatabase database;
Log.Out(Logs::General, Logs::Status, "Connecting to database...");
Log(Logs::General, Logs::Status, "Connecting to database...");
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
Log.Out(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a "
Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a "
"database connection");
return 1;
}
/* Register Log System and Settings */
database.LoadLogSettings(Log.log_settings);
Log.StartFileLogs();
database.LoadLogSettings(LogSys.log_settings);
LogSys.StartFileLogs();
ExportSpells(&database);
ExportSkillCaps(&database);
ExportBaseData(&database);
ExportDBStrings(&database);
Log.CloseFileLogs();
LogSys.CloseFileLogs();
return 0;
}
void ExportSpells(SharedDatabase *db) {
Log.Out(Logs::General, Logs::Status, "Exporting Spells...");
Log(Logs::General, Logs::Status, "Exporting Spells...");
FILE *f = fopen("export/spells_us.txt", "w");
if(!f) {
Log.Out(Logs::General, Logs::Error, "Unable to open export/spells_us.txt to write, skipping.");
Log(Logs::General, Logs::Error, "Unable to open export/spells_us.txt to write, skipping.");
return;
}
@@ -142,11 +142,11 @@ int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
}
void ExportSkillCaps(SharedDatabase *db) {
Log.Out(Logs::General, Logs::Status, "Exporting Skill Caps...");
Log(Logs::General, Logs::Status, "Exporting Skill Caps...");
FILE *f = fopen("export/SkillCaps.txt", "w");
if(!f) {
Log.Out(Logs::General, Logs::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
Log(Logs::General, Logs::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
return;
}
@@ -171,11 +171,11 @@ void ExportSkillCaps(SharedDatabase *db) {
}
void ExportBaseData(SharedDatabase *db) {
Log.Out(Logs::General, Logs::Status, "Exporting Base Data...");
Log(Logs::General, Logs::Status, "Exporting Base Data...");
FILE *f = fopen("export/BaseData.txt", "w");
if(!f) {
Log.Out(Logs::General, Logs::Error, "Unable to open export/BaseData.txt to write, skipping.");
Log(Logs::General, Logs::Error, "Unable to open export/BaseData.txt to write, skipping.");
return;
}
@@ -202,11 +202,11 @@ void ExportBaseData(SharedDatabase *db) {
}
void ExportDBStrings(SharedDatabase *db) {
Log.Out(Logs::General, Logs::Status, "Exporting DB Strings...");
Log(Logs::General, Logs::Status, "Exporting DB Strings...");
FILE *f = fopen("export/dbstr_us.txt", "w");
if(!f) {
Log.Out(Logs::General, Logs::Error, "Unable to open export/dbstr_us.txt to write, skipping.");
Log(Logs::General, Logs::Error, "Unable to open export/dbstr_us.txt to write, skipping.");
return;
}
@@ -25,7 +25,7 @@
#include "../../common/rulesys.h"
#include "../../common/string_util.h"
EQEmuLogSys Log;
EQEmuLogSys LogSys;
void ImportSpells(SharedDatabase *db);
void ImportSkillCaps(SharedDatabase *db);
@@ -34,35 +34,35 @@ void ImportDBStrings(SharedDatabase *db);
int main(int argc, char **argv) {
RegisterExecutablePlatform(ExePlatformClientImport);
Log.LoadLogSettingsDefaults();
LogSys.LoadLogSettingsDefaults();
set_exception_handler();
Log.Out(Logs::General, Logs::Status, "Client Files Import Utility");
Log(Logs::General, Logs::Status, "Client Files Import Utility");
if(!EQEmuConfig::LoadConfig()) {
Log.Out(Logs::General, Logs::Error, "Unable to load configuration file.");
Log(Logs::General, Logs::Error, "Unable to load configuration file.");
return 1;
}
auto Config = EQEmuConfig::get();
SharedDatabase database;
Log.Out(Logs::General, Logs::Status, "Connecting to database...");
Log(Logs::General, Logs::Status, "Connecting to database...");
if(!database.Connect(Config->DatabaseHost.c_str(), Config->DatabaseUsername.c_str(),
Config->DatabasePassword.c_str(), Config->DatabaseDB.c_str(), Config->DatabasePort)) {
Log.Out(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a "
Log(Logs::General, Logs::Error, "Unable to connect to the database, cannot continue without a "
"database connection");
return 1;
}
database.LoadLogSettings(Log.log_settings);
Log.StartFileLogs();
database.LoadLogSettings(LogSys.log_settings);
LogSys.StartFileLogs();
ImportSpells(&database);
ImportSkillCaps(&database);
ImportBaseData(&database);
ImportDBStrings(&database);
Log.CloseFileLogs();
LogSys.CloseFileLogs();
return 0;
}
@@ -97,10 +97,10 @@ bool IsStringField(int i) {
}
void ImportSpells(SharedDatabase *db) {
Log.Out(Logs::General, Logs::Status, "Importing Spells...");
Log(Logs::General, Logs::Status, "Importing Spells...");
FILE *f = fopen("import/spells_us.txt", "r");
if(!f) {
Log.Out(Logs::General, Logs::Error, "Unable to open import/spells_us.txt to read, skipping.");
Log(Logs::General, Logs::Error, "Unable to open import/spells_us.txt to read, skipping.");
return;
}
@@ -173,23 +173,23 @@ void ImportSpells(SharedDatabase *db) {
spells_imported++;
if(spells_imported % 1000 == 0) {
Log.Out(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
Log(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
}
}
if(spells_imported % 1000 != 0) {
Log.Out(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
Log(Logs::General, Logs::Status, "%d spells imported.", spells_imported);
}
fclose(f);
}
void ImportSkillCaps(SharedDatabase *db) {
Log.Out(Logs::General, Logs::Status, "Importing Skill Caps...");
Log(Logs::General, Logs::Status, "Importing Skill Caps...");
FILE *f = fopen("import/SkillCaps.txt", "r");
if(!f) {
Log.Out(Logs::General, Logs::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
Log(Logs::General, Logs::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
return;
}
@@ -220,11 +220,11 @@ void ImportSkillCaps(SharedDatabase *db) {
}
void ImportBaseData(SharedDatabase *db) {
Log.Out(Logs::General, Logs::Status, "Importing Base Data...");
Log(Logs::General, Logs::Status, "Importing Base Data...");
FILE *f = fopen("import/BaseData.txt", "r");
if(!f) {
Log.Out(Logs::General, Logs::Error, "Unable to open import/BaseData.txt to read, skipping.");
Log(Logs::General, Logs::Error, "Unable to open import/BaseData.txt to read, skipping.");
return;
}
@@ -265,11 +265,11 @@ void ImportBaseData(SharedDatabase *db) {
}
void ImportDBStrings(SharedDatabase *db) {
Log.Out(Logs::General, Logs::Status, "Importing DB Strings...");
Log(Logs::General, Logs::Status, "Importing DB Strings...");
FILE *f = fopen("import/dbstr_us.txt", "r");
if(!f) {
Log.Out(Logs::General, Logs::Error, "Unable to open import/dbstr_us.txt to read, skipping.");
Log(Logs::General, Logs::Error, "Unable to open import/dbstr_us.txt to read, skipping.");
return;
}
View
@@ -25,7 +25,7 @@ class EQEmuStackWalker : public StackWalker
}
}
Log.Out(Logs::General, Logs::Crash, buffer);
Log(Logs::General, Logs::Crash, buffer);
StackWalker::OnOutput(szText);
}
};
@@ -35,67 +35,67 @@ LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ACCESS_VIOLATION");
Log(Logs::General, Logs::Crash, "EXCEPTION_ACCESS_VIOLATION");
break;
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
Log(Logs::General, Logs::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
break;
case EXCEPTION_BREAKPOINT:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_BREAKPOINT");
Log(Logs::General, Logs::Crash, "EXCEPTION_BREAKPOINT");
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
Log(Logs::General, Logs::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
break;
case EXCEPTION_FLT_DENORMAL_OPERAND:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
break;
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
break;
case EXCEPTION_FLT_INEXACT_RESULT:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
break;
case EXCEPTION_FLT_INVALID_OPERATION:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
break;
case EXCEPTION_FLT_OVERFLOW:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_OVERFLOW");
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_OVERFLOW");
break;
case EXCEPTION_FLT_STACK_CHECK:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_STACK_CHECK");
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_STACK_CHECK");
break;
case EXCEPTION_FLT_UNDERFLOW:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_FLT_UNDERFLOW");
Log(Logs::General, Logs::Crash, "EXCEPTION_FLT_UNDERFLOW");
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
Log(Logs::General, Logs::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
break;
case EXCEPTION_IN_PAGE_ERROR:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_IN_PAGE_ERROR");
Log(Logs::General, Logs::Crash, "EXCEPTION_IN_PAGE_ERROR");
break;
case EXCEPTION_INT_DIVIDE_BY_ZERO:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
Log(Logs::General, Logs::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
break;
case EXCEPTION_INT_OVERFLOW:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INT_OVERFLOW");
Log(Logs::General, Logs::Crash, "EXCEPTION_INT_OVERFLOW");
break;
case EXCEPTION_INVALID_DISPOSITION:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_INVALID_DISPOSITION");
Log(Logs::General, Logs::Crash, "EXCEPTION_INVALID_DISPOSITION");
break;
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
Log(Logs::General, Logs::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
break;
case EXCEPTION_PRIV_INSTRUCTION:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_PRIV_INSTRUCTION");
Log(Logs::General, Logs::Crash, "EXCEPTION_PRIV_INSTRUCTION");
break;
case EXCEPTION_SINGLE_STEP:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_SINGLE_STEP");
Log(Logs::General, Logs::Crash, "EXCEPTION_SINGLE_STEP");
break;
case EXCEPTION_STACK_OVERFLOW:
Log.Out(Logs::General, Logs::Crash, "EXCEPTION_STACK_OVERFLOW");
Log(Logs::General, Logs::Crash, "EXCEPTION_STACK_OVERFLOW");
break;
default:
Log.Out(Logs::General, Logs::Crash, "Unknown Exception");
Log(Logs::General, Logs::Crash, "Unknown Exception");
break;
}
Oops, something went wrong.

1 comment on commit 7aa1d24

@mackal

This comment has been minimized.

Show comment
Hide comment
@mackal

mackal Apr 1, 2017

Member

Can you rename the macro to all caps? This is an almost universal standard and would be a good idea to keep following.

Member

mackal commented on 7aa1d24 Apr 1, 2017

Can you rename the macro to all caps? This is an almost universal standard and would be a good idea to keep following.

Please sign in to comment.