From 51e33796f14e91b26b78f62902ea80bffa555c20 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 3 Nov 2018 21:55:07 +0100 Subject: Optimize Parameter Control Loop For plugins with 10000 Control Inputs, dynamic_pointer_cast<> overhead is significant, here ~2msec (~0.2usec per cast, optimized build, i7-5600U, 2.60GHz) --- libs/ardour/plugin_insert.cc | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'libs/ardour/plugin_insert.cc') diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index 983d3b9aa8..5ecf652ce3 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -882,29 +882,20 @@ PluginInsert::connect_and_run (BufferSet& bufs, samplepos_t start, samplepos_t e uint32_t n = 0; - for (Controls::iterator li = controls().begin(); li != controls().end(); ++li, ++n) { - - boost::shared_ptr c - = boost::dynamic_pointer_cast(li->second); - - if (c->list() && c->automation_playback()) { + for (Controls::const_iterator li = controls().begin(); li != controls().end(); ++li, ++n) { + + /* boost::dynamic_pointer_cast<> has significant overhead, since we know that + * all controls are AutomationControl and their lists - if any - are AutomationList, + * we can use static_cast<>. This yields a speedup of 2.8/4.6 over to the + * previous code (measuerd with VeeSeeVSTRack 10k parameters, optimized build) */ + AutomationControl& c = static_cast (*(li->second)); + boost::shared_ptr clist (c.list()); + if (clist && (static_cast (*clist)).automation_playback ()) { bool valid; - - const float val = c->list()->rt_safe_eval (start, valid); - + const float val = c.list()->rt_safe_eval (start, valid); if (valid) { - /* This is the ONLY place where we are - * allowed to call - * AutomationControl::set_value_unchecked(). We - * know that the control is in - * automation playback mode, so no - * check on writable() is required - * (which must be done in AutomationControl::set_value() - * - */ - c->set_value_unchecked(val); + c.set_value_unchecked(val); } - } } } -- cgit v1.2.3