-
Notifications
You must be signed in to change notification settings - Fork 111
Description
Environment
- OS Version: Ubuntu 22.04
- Source
Description
- Expected behavior: Destroying
sdf::Element
should be relatively fast. - Actual behavior:
sdf::Element
takes forever to destroy.
Steps to reproduce
Here is a minimal program:
#include <sdf/Model.hh>
#include <sdf/Root.hh>
void deserialize()
{
std::string sdf = "<?xml version=\"1.0\" ?><sdf version='1.6'></sdf>";
sdf::Root root;
sdf::Errors errors = root.LoadSdfString(sdf);
if (!root.Model())
{
return;
}
sdf::Model _model = *root.Model();
return;
}
int main(int argc, char **argv)
{
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
deserialize();
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
std::cout << "Whole function call took: " <<
std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count()
<< "[µs]" << std::endl;
}
On my 8 core intel i7-11850H @ 2.50GHz with 64GB of ram I get the following slow speed:
Whole function call took: 108759[µs]
I.E: It takes 0.1s to parse, validate and destroy what is effectively an empty xml file. We use this function extensively in Gazebo. For instance, when we serialize and deserialize model components. In fact this exact set of steps runs everytime a model is deserialized, hence when we try to run 3k_worlds.sdf
where we load 3k shapes, we end up spending 300s just to deserialize the initial scene to the user. In fact when we run perf on the simulated world during, we see a large amount of time being spent inside the sdf library. Additionally, if we were to exit early (as done in this hack) instead of trying to deserialize we see a massive speedup (22s to load vs 300s, I suspect there is additional overhead caused by this bug inside renderutils as well). There are other places where we create and destroy, sdf elements within gazebo fairly frequently, I think its important we address this issue as it can lead to a much better user experience for end-users.
Output
Metadata
Metadata
Assignees
Labels
Type
Projects
Status