Why does performance decrease when removing / inserting models?
I've a world plugin that does the following:
- Insert a model (in this contrived example it's a simple sphere)
- Run for 5 seconds simulation time
- Measure the elapsed real time, calculate and print the real time factor, and remove the model
- Repeat
This is a rather contrived simplification of a legitimate use case. I'm doing this with the server only, i.e. no GUI, in Gazebo 6.1. Even though the performed simulation is exactly the same each time, the real time factor decreases rapidly. The decrease is actually superlinear (quadratic?), as evidenced by this plot of the real time factors:
It would therefore seem that something related to the old models lingers and slows everything down. I'd like to investigate and hopefully solve this issue, but I have no idea what could be causing this. My question, therefore, is whether anyone has an idea where this might come from?
There are known issues with improper clean up when deleting models, both on the server and the client. Even though the problem goes beyond visuals, I think [this](https://bitbucket.org/osrf/gazebo/issues/1702/removing-models-leaves-behind-some-visuals) issue is the one capturing the problem.
do you delete and add the exactly same model ? if yes they should have the same performance
Yes, it is exactly the same model - so yes the performance should be the same.. But it is not. @chapulina I'm gonna check that out.
I had this problem too. When doing evolution, if you keep the best individual of a generation, this individual should behave the same in next generation to learn. but if it will not, then the evolution has no effect. To avoid this I stopped and restarted simulation at each generation...
@chapulina Are the visuals even loaded though when only the server is used?
On the server side, rendering is only used for sensors, like cameras.
I noticed that, but I'm not using any sensors for this test at the moment. Put some print statements in Visual just in case, none are created, so it can't be that...
@Elte Hupkes onlty server without visualisation
@djou07 Similar use case then, since I'm also doing evolution. Restarting the simulation seems like a huge overhead... Also my requirements include some online evolution scenarios, so it's not really an option. Dead set on fixing this ;).