Closed adamkewley closed 4 months ago
Speedup appears to be roughly 5 % on Rajagopal
, which uses MillardEquilibriumMuscle
:
Test Name | lhs [secs] | σ [secs] | rhs [secs] | σ [secs] | Speedup |
---|---|---|---|---|---|
ToyDropLanding_nomuscles | 0.04 | 0.00 | 0.04 | 0.00 | 1.11 |
RajagopalModel | 3.82 | 0.00 | 3.59 | 0.00 | 1.06 |
Gait2354 | 0.20 | 0.00 | 0.19 | 0.00 | 1.03 |
passive_dynamic_noanalysis | 1.22 | 0.00 | 1.23 | 0.00 | 1.00 |
passive_dynamic | 1.83 | 0.00 | 1.82 | 0.00 | 1.00 |
Arm26 | 0.17 | 0.00 | 0.16 | 0.00 | 1.03 |
ToyDropLanding | 0.04 | 0.00 | 0.04 | 0.00 | 1.02 |
New approach: check if it's a path/name at runtime
Doing it this way means that no downstream (from OpenSim::Component
) code needs to change - for the cost of having to check if the string contains a directory separator.
If the string check is too expensive then we'd need to add overrides like getStateVariableValueByName
so that code can explicitly state that the thing being provided is a name, not a path. However, I have avoided doing this here because it makes the overall API more confusing (some methods would be byName
others would be suffix-less, but implicitly require a name (e.g. getOutput
), and so on).
Test Name | lhs [secs] | σ [secs] | rhs [secs] | σ [secs] | Speedup |
---|---|---|---|---|---|
ToyDropLanding_nomuscles | 0.04 | 0.00 | 0.04 | 0.00 | 1.07 |
RajagopalModel | 3.69 | 0.00 | 3.45 | 0.00 | 1.07 |
Gait2354 | 0.19 | 0.00 | 0.19 | 0.00 | 1.02 |
passive_dynamic_noanalysis | 1.21 | 0.00 | 1.21 | 0.00 | 1.00 |
passive_dynamic | 1.81 | 0.00 | 1.81 | 0.00 | 1.00 |
Arm26 | 0.16 | 0.00 | 0.16 | 0.00 | 1.02 |
ToyDropLanding | 0.04 | 0.00 | 0.04 | 0.00 | 1.01 |
If you get a chance @nickbianco / @pepbos then this is ready for review.
It's mostly an isolated shortcut that handles the situation where (e.g.) getStateVariableValue
is called with something like "somevar"
. The previous implementation assumes that all incoming strings might be paths to other components, so it spends a fair bit of CPU time (5-10 % when using Rajagopal model) converting to a ComponentPath
, checking how many elements there are in the path, etc.
Instead, this version just checks if the path contains a ComponentPath::separator()
(added in this PR - it's why the diffs are bigger than necessary, but I was getting sick of seeing "/"
everywhere) and, if there's no separator, it does a direct lookup.
Note: the biggest gains for RajagopalModel are actually on getModelingInfo
, which is called a lot more, and suffers from the same logic.
@adamkewley, I should have clarified: the perf suite will run on the next commit after adding [perf-win].
[perf-win]
… and integrate into Millard muscles and scalar actuators
Brief summary of changes
ComponentPath
overrides for path-dependent parts ofComponent
's public interfaceComponentPath
, rather thanstd::string
, so that the path is pre-parsed ahead of time, which can improve performanceTesting I've completed
Looking for feedback on...
OpenSim::CompnentPath
to traverse a string when it's just the name of the value)CHANGELOG.md (choose one)
Performance analysis
Platform: Windows, self-hosted runner
This change is