Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  GC Alloc every frame ObiFixedUpdater (Burst)
#1
Hello,

I just recently purchased this asset to see if it would be possible to use it for simulating aerodynamics and ran into some performance issues when trying to simulate lots of fluid particles. The low hanging fruit seemed to be tons of GC Allocations per frame in the ObiFixedUpdater/ObiSolver (Using Burst).

The following profiler was run with about 10,000 particles with Collision and Density Contsraints enabled. I did notice that when Disabling Density, the GC Alloc drops quite abit and performance improves.

   

Density disabled:

   

Deep profiler shows that the issue comes from setting the capacity of the List every frame and calling ToArray on it. (I was able to fix this by just using an array instead of a list and only allocating memory when the capacity needed to grow).

   

Here is a video of the scene I was running and what I'm trying to do. Not sure if you have any better suggestions on how I could go about trying to do an aerodynamics simulation (for a high speed boat / hydroplane)?

Reply
#2
Hi,

(22-11-2022, 12:55 AM)skaughtx0r Wrote: Deep profiler shows that the issue comes from setting the capacity of the List every frame and calling ToArray on it. (I was able to fix this by just using an array instead of a list and only allocating memory when the capacity needed to grow).

Thanks for the detailed analysis! That code path os not part of the simulation though, and has nothing to do with density constraints: it only gets called when new simplices/particles are added to the simulation: should only be a problem if you're emitting a large amount of particles at very high speeds, very often (which fairly enough, seems to be your use case Sonrisa)

(22-11-2022, 12:55 AM)skaughtx0r Wrote: Here is a video of the scene I was running and what I'm trying to do. Not sure if you have any better suggestions on how I could go about trying to do an aerodynamics simulation (for a high speed boat / hydroplane)?


This approach won't work at all. In order to simulate a wind tunnel using density constraints, you have to completely fill the volume you're trying to simulate with particles. This is because each particle simulates a discrete, small volume of fluid: in areas where there are no particles, there's no fluid. This is usually the strength of particle-based simulations, because it focus computational resources only in areas where there's any fluid.

However, completely filling a volume using particles is a worst-case scenario: there's no way to save resources since fluid is everywhere, and particles aren't as accurate as cell-based methods, so you get the worst of both worlds.

Doing this in 2D is fine, because there's a lot less particles than in 3D. I would advise against using a particle-based simulation for a volumetric (3D) wind tunnel simulation though, since particle-based engines are designed for sparse simulations and using them to fill a volume is extremely wasteful. A cell-based (aka eulerian) simulation would be a much better fit, because it's guaranteed to simulate the entire volume, because discretization of space is regular, and because they map almost directly to GPU hardware so most of what you'll find is implemented in the GPU.

kind regards,
Reply
#3
(22-11-2022, 09:04 AM)josemendez Wrote: should only be a problem if you're emitting a large amount of particles at very high speeds, very often (which fairly enough, seems to be your use case Sonrisa)

Haha, I figured it was related to my use-case as I hadn't seen any other posts about it, but yeah, lots of particles at high speed.

(22-11-2022, 09:04 AM)josemendez Wrote: This approach won't work at all. In order to simulate a wind tunnel using density constraints, you have to completely fill the volume you're trying to simulate with particles. This is because each particle simulates a discrete, small volume of fluid: in areas where there are no particles, there's no fluid. This is usually the strength of particle-based simulations, because it focus computational resources only in areas where there's any fluid.

However, completely filling a volume using particles is a worst-case scenario: there's no way to save resources since fluid is everywhere, and particles aren't as accurate as cell-based methods, so you get the worst of both worlds.

Doing this in 2D is fine, because there's a lot less particles than in 3D. I would advise against using a particle-based simulation for a volumetric (3D) wind tunnel simulation though, since particle-based engines are designed for sparse simulations and using them to fill a volume is extremely wasteful. A cell-based (aka eulerian) simulation would be a much better fit, because it's guaranteed to simulate the entire volume, because discretization of space is regular, and because they map almost directly to GPU hardware so most of what you'll find is implemented in the GPU.

Ah ok, thanks for the advice! I'll look around to see if I can find something that can fit my needs better.
Reply