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/effectchainmanager.cpp | |
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/effectchainmanager.cpp')
-rw-r--r-- | src/effects/effectchainmanager.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/effects/effectchainmanager.cpp b/src/effects/effectchainmanager.cpp index 667b436a9e..0931c17f94 100644 --- a/src/effects/effectchainmanager.cpp +++ b/src/effects/effectchainmanager.cpp @@ -19,16 +19,16 @@ EffectChainManager::~EffectChainManager() { //qDebug() << debugString() << "destroyed"; } -void EffectChainManager::registerGroup(const QString& group) { - if (m_registeredGroups.contains(group)) { - qWarning() << debugString() << "WARNING: Group already registered:" - << group; +void EffectChainManager::registerChannel(const ChannelHandleAndGroup& group) { + if (m_registeredChannels.contains(group)) { + qWarning() << debugString() << "WARNING: Channel already registered:" + << group.name(); return; } - m_registeredGroups.insert(group); + m_registeredChannels.insert(group); foreach (StandardEffectRackPointer pRack, m_standardEffectRacks) { - pRack->registerGroup(group); + pRack->registerChannel(group); } } |