From aaf3e7438cf4f6e73411a5bb9409f09c3a82f7fa Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Fri, 11 Jun 2021 14:48:28 +0200 Subject: [PATCH] Use unordered maps for VST3 plugin instances The better algorithmic time complexity should help when using many (say, hundreds) of instances of a single VST3 plugin. --- CHANGELOG.md | 2 ++ src/common/communication/common.h | 2 +- src/common/communication/vst3.h | 3 ++- src/plugin/bridges/vst3-impls/plugin-proxy.h | 2 +- src/plugin/bridges/vst3.h | 2 +- src/wine-host/bridges/vst3.h | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee80ca98..dcf7c7df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ Versioning](https://semver.org/spec/v2.0.0.html). completely rewritten to use both shared memory and message passing to reduce expensive memory copies to a minimum. With this change the DSP load overhead during audio processing should now be about as low as it's going to get. +- Optimized the management of VST3 plugin instances to reduce the overhead when + using many instances of a VST3 plugin. - Prevented some more potential unnecessary memory operations during yabridge's communication. The underlying serialization library was recreating some objects even when that wasn't needed, which could in theory result in memory diff --git a/src/common/communication/common.h b/src/common/communication/common.h index bf4be761..53e84f9e 100644 --- a/src/common/communication/common.h +++ b/src/common/communication/common.h @@ -744,7 +744,7 @@ class AdHocSocketHandler { // This works the exact same was as `active_plugins` and // `next_plugin_id` in `GroupBridge` - std::map active_secondary_requests{}; + std::unordered_map active_secondary_requests{}; std::atomic_size_t next_request_id{}; std::mutex active_secondary_requests_mutex{}; accept_requests( diff --git a/src/common/communication/vst3.h b/src/common/communication/vst3.h index a40f1165..991b884b 100644 --- a/src/common/communication/vst3.h +++ b/src/common/communication/vst3.h @@ -526,7 +526,8 @@ class Vst3Sockets final : public Sockets { * would have one dedicated thread for handling function calls to these * interfaces, and then another dedicated thread just idling around. */ - std::map> + std::unordered_map> audio_processor_sockets; std::mutex audio_processor_sockets_mutex; }; diff --git a/src/plugin/bridges/vst3-impls/plugin-proxy.h b/src/plugin/bridges/vst3-impls/plugin-proxy.h index 7b7118e3..47db1806 100644 --- a/src/plugin/bridges/vst3-impls/plugin-proxy.h +++ b/src/plugin/bridges/vst3-impls/plugin-proxy.h @@ -529,7 +529,7 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy { /** * Memoizes `IEditController::getParameterInfo()`. */ - std::map parameter_info; + std::unordered_map parameter_info; }; /** diff --git a/src/plugin/bridges/vst3.h b/src/plugin/bridges/vst3.h index 1fed94f9..e8a2f31f 100644 --- a/src/plugin/bridges/vst3.h +++ b/src/plugin/bridges/vst3.h @@ -204,7 +204,7 @@ class Vst3PluginBridge : PluginBridge> { * `register_plugin_proxy()` in the constractor, and an instance is then * removed through a call to `unregister_plugin_proxy()` in the destructor. */ - std::map> + std::unordered_map> plugin_proxies; private: diff --git a/src/wine-host/bridges/vst3.h b/src/wine-host/bridges/vst3.h index 94f920f3..b499ce10 100644 --- a/src/wine-host/bridges/vst3.h +++ b/src/wine-host/bridges/vst3.h @@ -440,7 +440,7 @@ class Vst3Bridge : public HostBridge { * will cause all pointers to it to get dropped and the object to be cleaned * up. */ - std::map object_instances; + std::unordered_map object_instances; std::mutex object_instances_mutex; /**