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

Unexpectedly poor performance with large amounts of stationary objects. Need performance advice. (Node JS) #1309

Open
KitaSparkle opened this issue Aug 12, 2024 · 0 comments

Comments

@KitaSparkle
Copy link

Physics run without a renderer so rendering is not the issue.

A single Matter.Engine.update(this.engine, UPDATE_FREQUENCY, 1); each single call takes randomly from 30 to 120ms! (i recorded the time right before and right after the matter js update function, so nothing else is responsible for it).

I have an event attached to "collisionStart", and i calculated all my custom code takes no more than 1 ms.

There are several thousand objects sparsley scattered throughout the world, most of them are not even moving and not even touching. enableSleeping: true is set in parameters in the engine constructor and it doesn't really change anything. There's nothing dramatic happening in the simulation in terms of any events.I tried to set every possible parameter in the constructor to be lower than a default value:

Matter.Engine.create({ 
    enableSleeping: true,  
    constraintIterations: 1,   
    positionIterations: 3,   
    velocityIterations: 1  
});

Objects are pretty simple. Basically a bunch of circles, occasionally regular polygons. Accuracy is not as important as stability, but with those seemingly arbitrary spikes with 70ms, 90ms, i cannot achieve the thing i need the most.

There's no gravity in the system, its scale is set to 0, so it's like a top-down view.

Computer specs: 32 Gigabytes of RAM DDR3, processor intel core i7-4790, 4-core, 8-threaded, 3.60GHz.

There must be a way to make it faster and smoother. Am i missing some very important setting in matter js?

Details on world contents:

World is the size of 10 000 per 10 000. There are around 5 thousand simple circles mostly not moving. Also there are objects that are essentially several 5 or 6 circles bunched together via simple constraints, but they never exceed the number of 200.

I understand that many objects need more time to process them. I don't expect anything instantenous. But there must be a stable ground. Realistically i cannot afford having an iteration taking more than 50 milliseconds to complete. i need an advice.

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

No branches or pull requests

1 participant