in reply to Re: Re: Re: Externally managed threads using embedded Perl
in thread Externally managed threads using embedded Perl

Yep, that's pretty much it.

The existing script is SpamAssassin's spamd. It is designed to run on *nix and uses fork and signals and other stuff that don't work too well on Win32. It reads and writes from/to a socket.

I find C++ much more productive that Perl - I guess it's just a question of what you know <g>.

I'll do some work with cloning and see what happens.

BTW, if I:
my $spamtest = SpamAssassin::Mail::SpamAssassin->new(...) : shared;
will $spamtest be available in the clone if I perl_clone after this Perl code is executed?

You've been most helpful. Thanks.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Externally managed threads using embedded Perl
by BrowserUk (Patriarch) on Jan 08, 2004 at 06:30 UTC
    I find C++ much more productive that Perl - I guess it's just a question of what you know <g>.

    Well, I know (or perhaps, knew once) C++ also, and I find Perl infinitely more productive. But then again, I hated C++ from my first encounter. Time and experience only made things worse -- but I know I am in a minority in that view:)

    BTW, if I:
    my $spamtest = SpamAssassin::Mail::SpamAssassin->new(...) : shared;
    will $spamtest be available in the clone if I perl_clone after this Perl code is executed?

    I've never seen anyone use that syntax before, and a quick test seems to indicate that you cannot use :share in that way.

    use threads; use threads::shared; use Benchmark::Timer; $T = Benchmark::Timer->new() : shared; Unquoted string "shared" may clash with future reserved word at (eval +3) line 1, <> line 2. syntax error at (eval 3) line 1, near ") :"

    Any attempt to share a blessed reference usually results in an error.

    use threads; use threads::shared; use Benchmark::Timer; { my $T : shared; $T = Benchmark::Timer->new(); } Invalid value for shared scalar at (eval 5) line 1, <> line 5.

    So, I think the short answer is no.

    I assume you were hoping to share a single instance of spamassasin between the multiple interpreters. This will not work.

    Creating a unique instance in each interpreter would(may) probably work, but I have no idea how much memory that would consume.

    That would require a piece of suck-and-see engineering I am afraid. Unless anyone else knows better.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!

      Sorry, I didn't mean to insult you (or anyone) with my C++ comment. I don't know Perl at all (as illustrated in my code example) so C++ is guaranteed to be faster for me. Plus I have good C++ tools (VS.NET) and no real Perl tools (again, editing scripts using VS.NET).

      Fortunately, despite my dismal Perl code example, you understood my question. I can deal with the answer - thanks once again.

      Ideally what I would like to do is prevent running the SA startup/initialisation code more than once (or so). This stuff takes quite a while to crank up and will kill performance. If I can't share a single instance, can I somehow "clone" a pre-initialised instance? (Last question, I promise, at least until I get to do some experimentation tonight).

      If I can't clone the object I'll definitely have to have a pool of interpreters lying around. I'm not overly concerned by the memory consumption as ActivePerl already consumes a heap of memory anyway, I can't imagine a few more instances of SpamAssassin will make that much difference.

      Phil

        I certainly wasn't insulted. Many people like C++, I prefer C or smalltalk or even Java, but that's really just me:)

        Never having used spamassasin, any further comment on that would just be speculation.

        I can't think of any easy way to clone a pre-initialised instance, but you might find that the initialisation costs are mostly a first-time setup cost at the spamd end and that subsequent connections are relatively low? You'll have to try it I think.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        Hooray!