diff options
author | RJ Ryan <rryan@mixxx.org> | 2015-02-21 03:00:58 -0500 |
---|---|---|
committer | RJ Ryan <rryan@mixxx.org> | 2015-02-24 14:57:01 -0500 |
commit | 7652b566ba60809db54391a45600a5384ce82a70 (patch) | |
tree | 5e76c753dd17579548dcc4a0a1f4e8ec1ae43e4c /src/effects/effectchain.h | |
parent | 1f953c9fb595359d0c452e1bc3b0b31aba5ac586 (diff) |
Refactor use of strings in the engine. 10-20% callback speed improvement.
* Add ChannelHandle, a wrapper class for an integer handle that starts
at 0 and increments.
* Add ChannelHandleFactory for assigning integer handles to group
strings.
* Add ChannelHandleMap, an associative container mapping ChannelHandle
to a template data type T. Backed by a QVarLengthArray with a
pre-allocation of 256. Supports fast O(1) lookups (simple memory
indexing) and amortized O(1) inserts.
* Re-factor engine and effects code to use ChannelHandle.
* Update EffectProcessor to use ChannelHandleMap instead of QHash.
* Update EngineEffectChain to use ChannelHandleMap instead of QLinkedList.
I did two tests -- one with effects inactive and one with effects
active. I measured total-callback processing time improvements of 20%
(1 track, no effects) and 13% (2 tracks, effects enabled). From this I
conclude that the QHash and QLinkedList introduced tons of wasted
cycles (which agrees with my profiling results from a month or two
ago).
Test 1:
* No effects active
* optimize=portable
* single track playing for 1 minute
* began sampling 20 seconds in to get rid of the load-track jitters
Base:
Debug [Main]: Stat("SoundDevicePortAudio::callbackProcess prepare 1, Built-in Output","count=45014,sum=3.82151e+09ns,average=84896ns,min=26393ns,max=429257ns,variance=9.41766e+08ns^2,stddev=30688.2ns")
Experiment:
Debug [Main]: Stat("SoundDevicePortAudio::callbackProcess prepare 1, Built-in Output","count=44856,sum=3.02069e+09ns,average=67342ns,min=20400ns,max=323169ns,variance=5.93287e+08ns^2,stddev=24357.5ns")
Results:
Minimum: reduced by 22.7%
Maximum: reduced by 24.7%
Average: reduced by 20.7%
StdDev: reduced by 20.6%
Test 2:
* One effect active on [Master].
* One effect active on [Channel1]
* optimize=portable
* two tracks playing for 1 minute
* began sampling 20 seconds in to get rid of the load-track jitters
Base:
Debug [Main]: Stat("SoundDevicePortAudio::callbackProcess prepare 1, Built-in Output","count=44937,sum=4.76277e+09ns,average=105988ns,min=38434ns,max=326061ns,variance=1.49815e+09ns^2,stddev=38706ns")
Experiment:
Debug [Main]: Stat("SoundDevicePortAudio::callbackProcess prepare 1, Built-in Output","count=45191,sum=4.15799e+09ns,average=92009.3ns,min=31693ns,max=333664ns,variance=1.11131e+09ns^2,stddev=33336.3ns")
Results:
Minimum: reduced by 17.5%
Maximum: increase by 0.02%
Average: reduced by 13.2%
StdDev: reduced by 13.9%
Diffstat (limited to 'src/effects/effectchain.h')
-rw-r--r-- | src/effects/effectchain.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/effects/effectchain.h b/src/effects/effectchain.h index 30e16da50d..594eafdb36 100644 --- a/src/effects/effectchain.h +++ b/src/effects/effectchain.h @@ -8,6 +8,7 @@ #include "util.h" #include "effects/effect.h" +#include "engine/channelhandle.h" class EffectsManager; class EngineEffectRack; @@ -37,10 +38,10 @@ class EffectChain : public QObject { void setEnabled(bool enabled); // Activates EffectChain processing for the provided group. - void enableForGroup(const QString& group); - bool enabledForGroup(const QString& group) const; - const QSet<QString>& enabledGroups() const; - void disableForGroup(const QString& group); + void enableForChannel(const ChannelHandleAndGroup& group); + bool enabledForChannel(const ChannelHandleAndGroup& group) const; + const QSet<ChannelHandleAndGroup>& enabledChannels() const; + void disableForChannel(const ChannelHandleAndGroup& group); EffectChainPointer prototype() const; @@ -105,7 +106,7 @@ class EffectChain : public QObject { void enabledChanged(bool enabled); void mixChanged(double v); void insertionTypeChanged(EffectChain::InsertionType type); - void groupStatusChanged(const QString& group, bool enabled); + void channelStatusChanged(const QString& group, bool enabled); private: QString debugString() const { @@ -124,7 +125,7 @@ class EffectChain : public QObject { InsertionType m_insertionType; double m_dMix; - QSet<QString> m_enabledGroups; + QSet<ChannelHandleAndGroup> m_enabledChannels; QList<EffectPointer> m_effects; EngineEffectChain* m_pEngineEffectChain; bool m_bAddedToEngine; |