Thread safety of Bullet Issue

osushkov
Posts: 2
Joined: Wed Sep 01, 2010 10:40 am

Thread safety of Bullet Issue

Post by osushkov »

I am currently using Bullet in order to perform a large number of rigid body simulations (simply dropping a convex hull onto a floor and looking at the resulting orientation). I perform each simulation in its own separate world, each completely independent. Each world has its own separate btDefaultCollisionConfiguration, btCollisionDispatcher, btBroadphaseInterface, btSequentialImpulseConstraintSolver, and btDiscreteDynamicsWorld objects. I then insert a separate btConvexHullShape object into each world. I then run a simulation loop on each world in a separate thread.

There are completely no shared variables between threads in my program, each world is completely separate and has its own objects. If I run this with 1 thread everything world perfectly, if I run more than 1 thread concurrently then Bullet seems to get very very slow for no apparent reason and eat up increasing memory. Why does this happen?

Somewhere it was mentioned that the btGjkEpaSolver used by the ConvexHullShape is not thread safe. Is this the case? Even if the worlds are completely separate they cannot be simulated concurrently because of this? Is there a work around?

Thanks.
btomko
Posts: 11
Joined: Mon Aug 31, 2009 9:05 pm

Re: Thread safety of Bullet Issue

Post by btomko »

I had this exact problem. Open up src/LinearMath/btQuickProf.h, change

Code: Select all

//#define BT_NO_PROFILE 1
to

Code: Select all

#define BT_NO_PROFILE 1
, recompile the entire bullet library, and you will be good.
osushkov
Posts: 2
Joined: Wed Sep 01, 2010 10:40 am

Re: Thread safety of Bullet Issue

Post by osushkov »

Sweet, it works! Thanks. I think this kind of issue should be more visibly documented somewhere as it could be quite common.