diff options
author | Robert Adam <dev@robert-adam.de> | 2022-01-27 22:02:05 +0300 |
---|---|---|
committer | Robert Adam <dev@robert-adam.de> | 2022-03-27 10:49:59 +0300 |
commit | c21e16c25c4b8c3a49d8d6ae8583a6b73df8cb33 (patch) | |
tree | 5b24d298751ad62b04995286893eb0b41ddf2b93 /src | |
parent | 7d4dcd168d94e18ea30c5d080615459a4165c5d6 (diff) |
FEAT: Add profiling support for audio processing
This should allow to get detailed insights into the audio processing
performance when using the Tracy profiler.
Diffstat (limited to 'src')
-rw-r--r-- | src/murmur/AudioReceiverBuffer.cpp | 8 | ||||
-rw-r--r-- | src/murmur/AudioReceiverBuffer.h | 4 | ||||
-rw-r--r-- | src/murmur/Server.cpp | 11 | ||||
-rw-r--r-- | src/murmur/TracyConstants.h | 6 |
4 files changed, 29 insertions, 0 deletions
diff --git a/src/murmur/AudioReceiverBuffer.cpp b/src/murmur/AudioReceiverBuffer.cpp index 7ea752f19..f27217157 100644 --- a/src/murmur/AudioReceiverBuffer.cpp +++ b/src/murmur/AudioReceiverBuffer.cpp @@ -8,6 +8,8 @@ #include <algorithm> #include <cassert> +#include <Tracy.hpp> + AudioReceiver::AudioReceiver(ServerUser &receiver, Mumble::Protocol::audio_context_t context, const VolumeAdjustment &volumeAdjustment) : m_receiver(receiver), m_context(context), m_volumeAdjustment(volumeAdjustment) { @@ -65,6 +67,8 @@ void AudioReceiverBuffer::addReceiver(const ServerUser &sender, ServerUser &rece void AudioReceiverBuffer::forceAddReceiver(ServerUser &receiver, Mumble::Protocol::audio_context_t context, bool includePositionalData, const VolumeAdjustment &volumeAdjustment) { + ZoneScoped; + std::vector< AudioReceiver > &receiverList = includePositionalData ? m_positionalReceivers : m_regularReceivers; std::unordered_map< const ServerUser *, std::size_t > &userEntryIndices = includePositionalData ? m_positionalReceiverIndices : m_regularReceiverIndices; @@ -89,6 +93,8 @@ void AudioReceiverBuffer::forceAddReceiver(ServerUser &receiver, Mumble::Protoco } void AudioReceiverBuffer::preprocessBuffer() { + ZoneScoped; + preprocessBuffer(m_regularReceivers); preprocessBuffer(m_positionalReceivers); } @@ -109,6 +115,8 @@ std::vector< AudioReceiver > &AudioReceiverBuffer::getReceivers(bool receivePosi } void AudioReceiverBuffer::preprocessBuffer(std::vector< AudioReceiver > &receiverList) { + ZoneScoped; + #ifndef NDEBUG // Sort the list such that entries with same receiver are next to each other std::sort(receiverList.begin(), receiverList.end(), [](const AudioReceiver &lhs, const AudioReceiver &rhs) { diff --git a/src/murmur/AudioReceiverBuffer.h b/src/murmur/AudioReceiverBuffer.h index 236ca45ee..7a8741da3 100644 --- a/src/murmur/AudioReceiverBuffer.h +++ b/src/murmur/AudioReceiverBuffer.h @@ -14,6 +14,8 @@ #include <unordered_map> #include <vector> +#include <Tracy.hpp> + class AudioReceiver { public: AudioReceiver(ServerUser &receiver, Mumble::Protocol::audio_context_t context, @@ -61,6 +63,8 @@ public: template< typename Iterator > static ReceiverRange< Iterator > getReceiverRange(Iterator begin, Iterator end) { + ZoneScoped; + ReceiverRange< Iterator > range; range.begin = begin; diff --git a/src/murmur/Server.cpp b/src/murmur/Server.cpp index cc031825b..fce3efac6 100644 --- a/src/murmur/Server.cpp +++ b/src/murmur/Server.cpp @@ -37,6 +37,7 @@ #include "TracyConstants.h" #include <Tracy.hpp> +#include <TracyC.h> #include <algorithm> #include <vector> @@ -1209,11 +1210,15 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au QSet< ServerUser * > listener; if (u->qmTargetCache.contains(audioData.targetOrContext)) { + ZoneScopedN(TracyConstants::audio_whisper_cache_restore); + const WhisperTargetCache &cache = u->qmTargetCache.value(audioData.targetOrContext); channel = cache.channelTargets; direct = cache.directTargets; listener = cache.listeningTargets; } else { + ZoneScopedN(TracyConstants::audio_whisper_cache_create); + const WhisperTarget &wt = u->qmTargets.value(audioData.targetOrContext); if (!wt.qlChannels.isEmpty()) { QMutexLocker qml(&qmCache); @@ -1315,6 +1320,8 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au } } + ZoneNamedN(__tracy_scoped_zone2, TracyConstants::audio_send_out_zone, true); + buffer.preprocessBuffer(); bool isFirstIteration = true; @@ -1338,6 +1345,8 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au if (isFirstIteration || !Mumble::Protocol::protocolVersionsAreCompatible(encoder.getProtocolVersion(), currentRange.begin->getReceiver().uiVersion)) { + ZoneScopedN(TracyConstants::audio_encode); + encoder.setProtocolVersion(currentRange.begin->getReceiver().uiVersion); // We have to re-encode the "fixed" part of the audio message @@ -1353,7 +1362,9 @@ void Server::processMsg(ServerUser *u, Mumble::Protocol::AudioData audioData, Au audioData.targetOrContext = currentRange.begin->getContext(); // Update data + TracyCZoneN(__tracy_zone, TracyConstants::audio_update, true); gsl::span< const Mumble::Protocol::byte > encodedPacket = encoder.updateAudioPacket(audioData); + TracyCZoneEnd(__tracy_zone); // Clear TCP cache tcpCache.clear(); diff --git a/src/murmur/TracyConstants.h b/src/murmur/TracyConstants.h index 2b1120449..355eafd40 100644 --- a/src/murmur/TracyConstants.h +++ b/src/murmur/TracyConstants.h @@ -14,6 +14,12 @@ static constexpr const char *udp_ping_processing_zone = "udp_ping"; static constexpr const char *decrypt_unknown_peer_zone = "decrypt_unknown_peer"; static constexpr const char *udp_frame = "udp_frame"; + +static constexpr const char *audio_send_out_zone = "audio_send_out"; +static constexpr const char *audio_encode = "audio_encode"; +static constexpr const char *audio_update = "audio_update"; +static constexpr const char *audio_whisper_cache_restore = "audio_whisper_cache_restore"; +static constexpr const char *audio_whisper_cache_create = "audio_whisper_cache_create"; }; // namespace TracyConstants #endif // MUMBLE_MURMUR_TRACYCONSTANTS_H_ |