Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scene_graph: Broadphase culling may be insufficient (see profiling results of the geometry pipeline) #9439

Closed
3 tasks
amcastro-tri opened this issue Sep 12, 2018 · 2 comments · Fixed by #10184
Closed
3 tasks

Comments

@amcastro-tri
Copy link
Contributor

amcastro-tri commented Sep 12, 2018

Description

From #8942 we see that the contact queries comprise about 25% of the total cost. This is a very simple case for which most of the simulation 16 spheres (2 pads modeled with 8 spheres each) collide against a single cylinder (a simple mug model). That is, there are 16 calls to sphereCylinderIntersect() per time step.

Reproduction

Instructions on how to reproduce these profiling results are documented in #8942.

Profiling Results

In a computation with 20,000 time steps, 26% of the cost is spent in the computation of geometric queries starting at MBP::CalcPointPairPenetrations() (called once per time step, e.g., 20,000 invocations).

The breakdown is quite complex given the large stack of calls. However the big take away is the cost in actual computation of contact information:

  • fcl::detail::sphereCylinderIntersect<double>(): 0.57%, called 320,000 times (16 x 20,000 steps)

That is most of our 26% is overhead.

Remarks

drake::geometry::internal::(anonymous namespace)::CollisionFilterLegacy::CanCollideWith() (on Drake's side, not FCL) is taking alone 9.8% of the total cost that is, 40% of the contact pipeline.
Another important data point is that it gets called a total of 14M times over the 20K time steps (verified that each time step performs a single call to ProximityEngine::ComputePointPairPenetration()).

Action Items

  • Identify the three most time consuming calls in the pipeline.
  • Fix each item one at a time in order of importance.
  • Profile the example again after these improvements are introduced to find out next bottleneck in the chain.
@SeanCurtis-TRI
Copy link
Contributor

It's also worth drawing a line between the drake side of the code and the fcl side of the code. The entry point is MBP::CalcPointPairPenetrations() which calls SG which calls FCL. It'd be good to see the distribution of cost between drake and FCL.

@amcastro-tri amcastro-tri changed the title Preliminary profiling results of the FCL geometry pipeline. Profiling results of the geometry pipeline. Sep 12, 2018
@EricCousineau-TRI EricCousineau-TRI changed the title Profiling results of the geometry pipeline. scene_graph: Broadphase culling may be insufficient (see profiling results of the geometry pipeline) Oct 31, 2018
@SeanCurtis-TRI
Copy link
Contributor

Off of master, I was able to reproduce this. For the 8 spheres per ring, I was able to get consistent results of QueryObject::ComputePointPairPenetration() at ~30% of the calls. I further confirmed that the number of calls to the collision filtering was exactly all of the potential pairs always. Literally, nothing was being culled by the broadphase, ever.

The answer proved to be simple and is shown in the related PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants