CGRU / cgru

CGRU - AFANASY
http://cgru.info/
GNU Lesser General Public License v3.0
278 stars 111 forks source link

multi-thread for-loop in hasTickets #596

Open ultra-sonic opened 7 months ago

ultra-sonic commented 7 months ago

Hey Timur,

we are still chasing performance over here at RISE and I think we have spotted a part of the afserver code that can potentially be mutli-threaded easily.

I am talking about the for-loop in the hasTickets function over here: https://github.com/CGRU/cgru/blob/a1b60c5ad70dca24ef67f02549449106784fd02b/afanasy/src/server/renderaf.cpp#L801

This is one of the largest bottlenecks in the performance analysis from @sebastianelsner in #592

what do you think?

cheers Oli

timurhai commented 7 months ago

Hello, Oli! If most time solving finds out tickets and this is read-only function, we can try to slit solving on reading and writing sections. Launch several threads to solve (for the entire solve and to read and to write) and block writing secions to run only by thie one thread at the same time. Yes, this is the easiest way, i think.

ultra-sonic commented 7 months ago

we have just tried using OpenMP to multithread the hasTickets function but it seems that the overhead of spawning new threads is bigger than the benefit that the multi-threading would give.

Another solution could be a thread-pool to mitigate the overhead of frequent thread creation and destruction, especially with small task sizes.

Do you think this is a viable way to go?

cheers Oli