Doraku / DefaultEcs

Entity Component System framework aiming for syntax and usage simplicity with maximum performance for game development.
MIT No Attribution
658 stars 62 forks source link

AEntitySetSystem<T> invokes runner in single-threaded mode #140

Closed nrader95 closed 2 years ago

nrader95 commented 2 years ago

So we encounteres synchronization lags in our single-threaded (!) systems. After i bit of reading through the source code of AEntitySetSystem, culprit seem to be this:

                    _runnable.CurrentState = state;
                    _runnable.EntitiesPerIndex = Set.Count / _runner.DegreeOfParallelism;

                    if (_runnable.EntitiesPerIndex < _minEntityCountByRunnerIndex)
                    {
                        Update(state, Set.GetEntities());
                    }
                    else
                    {
                        _runner.Run(_runnable);
                    }

This triggers the use of runner when we don't need it.

Other systems that support runners seems to have this bug as well.

Doraku commented 2 years ago

Sorry for the late reply, didn't get much free time the last weeks sadly. Did you mesure the actual impact? This just add two virtual calls (IParallelRunner.Run and IPArallelRunnable.Run) which should be pretty negligible next to the actual processing of all the entities.

nrader95 commented 2 years ago

No, i did not measure, at least not precisely. The game started to run a bit smoother after changes, tho.