Re: Utilizing multiple cores in a function call.

From: Greg Smith <gsmith(at)gregsmith(dot)com>
To: "Hartman, Matthew" <Matthew(dot)Hartman(at)krcc(dot)on(dot)ca>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Utilizing multiple cores in a function call.
Date: 2009-06-29 18:42:18
Message-ID: alpine.GSO.2.01.0906291429000.28239@westnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, 29 Jun 2009, Hartman, Matthew wrote:

> The function throttles one of my CPUs to 100% (shown as 50% in Task
> Manager) and leaves the other one sitting pretty. Is there any way to
> use both CPUs?

Not easily. Potential techniques:

-Rewrite the function or its time critical portion in some other language
that allows using two processes usefully

-Write a "worker server" that you prompt to pick up work from a table and
write its output to another that you can ask to handle part of the job.
You might communicate with the worker using the LISTEN/NOTIFY mechanism in
the database.

-Some combination of these two techniques. One popular way to speed up
things that are running slowly is to run some part of them in a C UDF, so
that you could use "select my_big_computation(x,y,z)" and get faster
execution.

If you were hoping for a quick answer, no such thing. I suspect you'd get
better help talking about what your function does and see if there's a
specific part somebody else is familiar with optimizing.

For example, I've seen >10:1 speedups just be rewriting one small portion
of a computationally expensive mathematical function in C before, keeping
the rest of the logic on the database side. You don't necessarily have to
rewrite the whole thing.

--
* Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2009-06-29 21:21:32 Re: Utilizing multiple cores in a function call.
Previous Message Joe Conway 2009-06-29 18:20:21 Re: Utilizing multiple cores in a function call.