box2d.ts icon indicating copy to clipboard operation
box2d.ts copied to clipboard

v1.0.1 significant performance decrease compared to v1.0.0

Open Fxlr8 opened this issue 5 years ago • 3 comments

Hi, I have just updated my game backend to a newer version of box2d.ts and the performande dropped a lot. I do a lot of QueryAABB and fixture.synchronize calls for my game's needs. I noticed that Solve takes more CPU now and GC became more aggressive.

v1.0.0 image v1.0.1 image

The game code is the same in both cases. The game is playable on v1.0.0, but on v1.0.1 heavy lags appear because the server can't output enough frames per second.

Fxlr8 avatar Dec 27 '19 00:12 Fxlr8

In this version, there was a change to b2Body:SynchronizeFixtures that uses the center of mass instead of the transform position. This may be causing the proxy AABB's to be updated more often. I'm not sure what might be causing the GC. I recall using for..of loops for iterating in some places; perhaps this is generating garbage. I'll have to look into it further. For now, you might consider switching back to 1.0.0.

flyover avatar Dec 27 '19 02:12 flyover

https://stackoverflow.com/questions/18364175/best-practices-for-reducing-garbage-collector-activity-in-javascript

@flyover hi, FYI.

jcyuan avatar Sep 25 '20 14:09 jcyuan

Did some digging. The biggest performance drop comes from moving the math stuff to Float32Array.

Lusito avatar Oct 02 '20 15:10 Lusito