-
-
Notifications
You must be signed in to change notification settings - Fork 369
lib/gis: solve write out conflicts of G_percent/G_progress when multithreading #6121
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
base: main
Are you sure you want to change the base?
Conversation
Thanks! There is probably no better solution, but I think this still needs some benchmark whether this has any impact on the speed. |
This should not be merged, as:
|
It is a very small part, so I believe its impact could be negligible. I simply ran I would like to get some benchmarks on r.mapcalc after #5742 is merged.
@marisn Can you elaborate on why you think it does not solve #5776? |
I ran the benchmark of @petrasovaa could you test this on your end to double-check? ![]() ![]() ![]() ![]() |
I agree with @marisn because it can significantly slow down parallel performance. The above benchmark testing is just one of many possible cases and higher speedup is, I believe, just a noise because that's not possible theoretically or at least cannot easily be explained when critical sections are introduced. |
@cyliang368 Could you test it again without calling |
I have doubts about the caller code (tool level code) being correct even with this change. If you simply show the percentage from each thread, it will not reflect the overall progress. That's possible to show only when the threads sync their work. If they don't, better not to show anything, or resort to some heuristic like showing progress from the first thread only. |
1 similar comment
I have doubts about the caller code (tool level code) being correct even with this change. If you simply show the percentage from each thread, it will not reflect the overall progress. That's possible to show only when the threads sync their work. If they don't, better not to show anything, or resort to some heuristic like showing progress from the first thread only. |
You are correct. When multiple threads call G_percent, the output will not be correct as each thread will push % counter to its progress position (thread work position in all work queue) instead of overall progress (aggregate of total work done). |
Better, but an if condition checking for the first thread would be easier for 8.5, no? |
@wenzeslaus you are right. However, I will say using 1 thread can make things worse. Let's say we specify In the first batch ( In the second batch ( Unless @marisn has a better idea, I think 1 thread makes things worse. This problem is not from If we really care about computational performance and believe locks are a bottleneck, I would say it might be better not to print out everything. The fact is that However, I still believe |
Technically, as being C11, we can make use of _Atomic for the counter, if that could be part of a solution. |
If you are running it as part of a Python script or in a notebook, you will not see any of that cautiously computed percentage. What about just showing a rotating thingy from the first thread to show the process is still alive? |
This PR should solve #5776.
If we want to solve writing conflicts to the same place (stderr), it must be serial.