Skip to content

Optimization. #215

@Voidx

Description

@Voidx

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>();
                uint32 itemId = (*result)[1].Get<uint32>();
                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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions