in reply to Re^2: Share symbol table between threads
in thread Share symbol table between threads

Ah I get it. You're letting the threads die after handling a request and starting a new thread per request.

If you're concerned about performance, the general advice is to have a persistent thread pool, with the number of threads proportional to the number of execution cores on your system.

There appears to be a CPAN module, Thread::Pool which automates this process. If you did this, then you'll just require the modules in-thread and they'll only be loaded once per thread. Looking at the docs, you'll want max == min so that threads don't die off.

There are performance tradeoffs here. Using a pool should reduce mean latency (since you don't have to start a new perl thread before handling the request) but may introduce unpredictably to the latency, since the pool may be at max when a new request comes in. An appropriately-sized pool should increase the throughput (ops/second) since less work is being done per op (you aren't starting a whole new thread).

  • Comment on Re^3: Share symbol table between threads

Replies are listed 'Best First'.
Re^4: Share symbol table between threads
by jwu (Novice) on Oct 04, 2006 at 13:22 UTC
    Thanks jbert,

    I will keep that in mind, but for now, I will choose the simple solution by ``require'' it every time.

    The principle of this module is to be simple. The whole module only in 200 lines (thanks for AUTOLOAD). I probably use Thread::Pool as a plugin later.

    By the way, the module will be on CPAN as RPC::Object (wait some time before it appears). Thanks for your help.