Skip to content

Parallel Query #49

Answered by friflo
MaansenV asked this question in Q&A
Jun 3, 2024 · 3 comments · 2 replies
Discussion options

You must be logged in to vote

Thx,

The interesting numbers are:

JobRunner - thread count:              16
QueryJob  - MinParallelChunkLength:    1000

and entities: 5001

16 threads => 5000 / 16 = 312 entities per chunk.
Assuming all entities are in a single Archetype.

Using multi threading in RunParallel() requires:
entities per chunk must be > MinParallelChunkLength.

If the threshold is not met Query.ForEach(...) is executed single threaded.
So lower MinParallelChunkLength to 100 or 10.
In your case the computation in Query.ForEach(...) is significant.

The reason for a threshold is to avoid multi treading if the cost for thread synchronization is too high.
It is about 1 - 2 micro seconds per thread - an eternity :)

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@MaansenV
Comment options

Comment options

You must be logged in to vote
1 reply
@friflo
Comment options

Answer selected by MaansenV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants