azerothcore / azerothcore/mod-transmog
Optimization.
- Dominant language
- C++
- Stars
- 189
- Forks
- 205
- PR merge metrics
- No merged PRs in 30d
Description
Suggested Optimization: Lazy Per-Account Loading + Avoid Full Reload on .reload config
Currently, the module loads all unlocked appearances during the OnAfterConfigLoad hook, which means the entire custom_unlocked_appearances table is read every time .reload config is executed.
On large servers this can exceed 1.8 GB of data being loaded into memory at once.
Current code:
```
`void OnAfterConfigLoad(bool reload) override
{
sT->LoadConfig(reload);
if (sT->GetUseCollectionSystem())
{
LOG_INFO("module", "Loading transmog appearance collection cache....");
uint32 collectedAppearanceCount = 0;
QueryResult result = CharacterDatabase.Query("SELECT account_id, item_template_id FROM custom_unlocked_appearances");
if (result)
{
do
{
uint32 accountId = (*result)[0].Get();
uint32 itemId = (*result)[1].Get();
if (sT->AddCollectedAppearance(accountId, itemId))
{
collectedAppearanceCount++;
}
} while (result->NextRow());
}
LOG_INFO("module", "Loaded {} collected appearances into cache", collectedAppearanceCount);
}
}`
```
Do not load the full table inside OnAfterConfigLoad, since this hook runs every time .reload config is used.
Implement lazy loading per-account, for example:
load a player’s unlocked appearances only when they log in;
optionally free the cache on logout to reduce memory usage.
Keep OnAfterConfigLoad strictly for config reloads, not for large dataset initialization.
Benefits:
No heavy delay or memory spike when using .reload config.
Significantly reduced memory usage.
Cache size scales with active players, not with total table size.
Faster worldserver startup.
This would be a strong improvement for large servers with big transmog datasets.
@Nyeriah
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with OnAfterConfigLoad and the custom_unlocked_appearances query shown in the issue, then trace where account appearance data is accessed during login and logout. Keep configuration reloads free of full-table loading; done means account data loads on demand, optional logout cleanup works, and the cache scales with active players.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend, databases, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100