Reputation: 5186
I have a server with 2 physical CPU which have together 24 cores and 10 GB RAM. The PHP program is calculating a statistic and I could run each section totally independent of the others. Once all calculations finished I have only to "merge" them.
Therefore I had the idea to perform each calculation phase in a separate thread created/controlled by "pthread". Each calculation takes around 0,10 seconds but the amount of the calculations lets it take that long when they are serialized.
My questions:
I can imagine that for several seconds the load would be very high but then it ends suddenly once each calculation finished. This is not the problem. It is "my" server and I do not have to take care regarding other users [or when it is a shared server].
Upvotes: 0
Views: 602
Reputation: 5186
While "waiting" for an answer :-) I started to rewrite the class.
I can summarize it like this:
Franz Gleichmann
pointed out the whole process took longer when starting lot of threads. I found out that starting 20 threads has the best performance.pthread
library but I could not access any class members. I had to move the class members inside the function. Due to the fact the calculation is in one function it did not bother me and I do not investigate it further.Upvotes: 1