spike in CPU usage when enabling an effect for the first time

Bug #1662374 reported by Be
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
Medium
Be

Bug Description

I can't reproduce this reliably, but when it happens it causes an xrun. Thereafter, enabling effects works fine.

Changed in mixxx:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Daniel Schürmann (daschuer) wrote :
Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

The system was designed to pre-allocate all group state on the main thread for groups that exist when the effect is instantiated.

It looks like this isn't working for the default effect chains because they are created before the decks/samplers/etc. are setup.
https://github.com/mixxxdj/mixxx/blob/master/src/mixxx.cpp#L189

Be: Were you using master or was this using your persistent effects branch? Since you load effects in EffectsManager::setupDefaults(), the loaded effects will also not get their group state pre-instantiated.

It should be safe to move setupDefaults() to after the decks/samplers/mics/auxiliaries are setup.

Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

Though this won't work for e.g. the P32 MIDI script which creates 32 samplers when the controller script is evaluated. If you enable an effect unit for one of these samplers you'll hit the same memory allocation in the callback.

It's also wasteful to allocate group state for every effect for all groups -- especially if something like the P32 is creating 32 samplers.

Perhaps a better solution would be that when we write an ENABLE_EFFECT_CHAIN_FOR_CHANNEL message from the main thread to the engine, we also send a message for every effect in the chain containing an instance of the group state for that effect. We will also have to write group state for every enabled channel whenever we add a new effect to the chain.

Revision history for this message
Be (be.ing) wrote :

> Were you using master or was this using your persistent effects branch?

I think I have experienced this issue with both, but I'll check when it happens again.

> Though this won't work for e.g. the P32 MIDI script which creates 32 samplers when the controller script is evaluated. If you enable an effect unit for one of these samplers you'll hit the same memory allocation in the callback.

FWIW there is no way with the P32 mapping to assign a sampler to an effect unit.

Revision history for this message
Daniel Schürmann (daschuer) wrote :

> Perhaps a better solution would be that when we write an ENABLE_EFFECT_CHAIN_FOR_CHANNEL message from the main thread to the engine, we also send a message for every effect in the chain containing an instance of the group state for that effect. We will also have to write group state for every enabled channel whenever we add a new effect to the chain.

This Sounds like a good plan. .. and entirely remove the singleton thing from the process call.

Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

> This Sounds like a good plan. .. and entirely remove the singleton thing from the process call.

Singleton thing?

Revision history for this message
Daniel Schürmann (daschuer) wrote :

Not a real singleton, just this:

if (holder.state == NULL) {
    holder.state = new T();
}

Revision history for this message
Be (be.ing) wrote :

I am doubtful that the "new T()" in PerChannelEffectProcessor::getOrCreateChannelState is causing this issue. In https://github.com/mixxxdj/mixxx/pull/1254 I have moved the initialization of EffectChains/EngineEffectChains and Effects/EngineEffects after the registration of input & output channels with EffectsManager, but now this issue seems to be occurring more often. Do you have any suggestions for tracking down the source of the issue?

Revision history for this message
Daniel Schürmann (daschuer) wrote :

Is this one fixed? I think yes.

Revision history for this message
Be (be.ing) wrote :

Yes this was fixed with the EffectState memory handling refactoring for postfader effects in 2.1 https://github.com/mixxxdj/mixxx/pull/1254

Changed in mixxx:
status: Confirmed → Fix Committed
status: Fix Committed → Fix Released
assignee: nobody → Be (be.ing)
Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/8793

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.