[erlang-questions] CPU not reaching 100%
Sergey Samokhin
prikrutil@REDACTED
Mon Jul 20 21:38:35 CEST 2009
Hello.
> I've a simple process which in turn spawns 10 more processes - each hitting
> mnesia ram_tables continuously. As soon as all 10 processes are started, the
> CPU usage goes up (2 CPUs, 2 cores each). However, none of of the CPUs
> touches 50% - they all seem to churn at around 43-45%..
I have got some ideas to examine.
Some of processes you spawn may blocks in receive statement waiting
for a message (note that receive statement may be hidden inside common
library functions you're using, say in gen_tcp:recv/2). To know what a
process you are interestend in is doing try to call:
process_info(Pid, current_function)
It may throw light on the place where the problem is.
Are your ram_tables replicated across several nodes? If so, you should
take into account that having to send some TCP messages per each
transaction through a network blocks mnesia:transaction/1 until all
the replicas become synchronized.
> How do I increase CPU utilization?
At first you should find out where your processes spend their time and
then try to get rid of those bottlenecks. Posting source code with
small example illustrating your problem will be very helpful for those
who can say "Aha, I know what actually is wrong!"
> Is there a flag I should be passing? Is 'kernel-poll:false' is sometthing I
> need to worry about?
I don't think that turning kernel polling on (by passing +K to erl)
will make your CPU as busy as you want. It's often used when dealing
with sousands of sockets.
--
Sergey Samokhin
More information about the erlang-questions
mailing list