diff --git a/Makefile b/Makefile index 1780121e..145d2bab 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,8 @@ perf: $(TARGET) # Requires gperftools perf record --call-graph dwarf -o perf.data ./$< -d # Analyze with hotspot (https://github.com/KDAB/hotspot) for example - # hotspot perf.data + hotspot perf.data + rm perf.data valgrind: $(TARGET) # --gen-suppressions=yes diff --git a/include/simd/sse_mathfun.h b/include/simd/sse_mathfun.h index 64188187..69b74d33 100644 --- a/include/simd/sse_mathfun.h +++ b/include/simd/sse_mathfun.h @@ -45,7 +45,7 @@ This derived source file is released under the zlib license. */ -#include +#include /** Generate 1.f without accessing memory */ diff --git a/include/simd/vector.hpp b/include/simd/vector.hpp index ce1ec3ed..a043f6bf 100644 --- a/include/simd/vector.hpp +++ b/include/simd/vector.hpp @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace rack { diff --git a/src/Core/AudioInterface.cpp b/src/Core/AudioInterface.cpp index 093ed7a3..92c5edb2 100644 --- a/src/Core/AudioInterface.cpp +++ b/src/Core/AudioInterface.cpp @@ -132,7 +132,6 @@ struct AudioInterface : Module { if (port.active && port.numInputs > 0) { // Wait until inputs are present // Give up after a timeout in case the audio device is being unresponsive. - APP->engine->yieldWorkers(); std::unique_lock lock(port.engineMutex); auto cond = [&] { return (!port.inputBuffer.empty()); @@ -182,11 +181,12 @@ struct AudioInterface : Module { if (outputBuffer.full()) { // Wait until enough outputs are consumed // Give up after a timeout in case the audio device is being unresponsive. - APP->engine->yieldWorkers(); - std::unique_lock lock(port.engineMutex); auto cond = [&] { return (port.outputBuffer.size() < (size_t) port.blockSize); }; + if (!cond()) + APP->engine->yieldWorkers(); + std::unique_lock lock(port.engineMutex); auto timeout = std::chrono::milliseconds(200); if (port.engineCv.wait_for(lock, timeout, cond)) { // Push converted output diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 6b14c05f..4b1b6cf1 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -9,8 +9,7 @@ #include #include #include -#include -#include +#include namespace rack { @@ -90,7 +89,9 @@ struct SpinBarrier { count = 0; } else { - while (count != 0); + while (count != 0) { + _mm_pause(); + } } } }; @@ -127,6 +128,7 @@ struct HybridBarrier { while (!yield) { if (count == 0) return; + _mm_pause(); } // Wait on mutex