One good thing the guys from Java 1.5 did was putting the modules in shared memory, so different JVMs running on the same machine can share the loaded modules.

So I was wondering... Is it possible in Perl? Maybe in Perl6? The dynamic nature of the language is something that makes it harder or even impossible?

UPDATE: Just to clarify, when I mean shared, it's in the sense of shared libraries, which are shared among unrelated proccesses, and not by one proccess and its children.

UPDATE2: Well... I was wrong... Searching for more information on what Sun calls "Class Data Sharing", I saw it only does it for some core libraries, namely, that in rt.jar and only for the Java Hotspot Client VM. http://java.sun.com/j2se/1.5.0/docs/guide/vm/class-data-sharing.html

daniel

Replies are listed 'Best First'.
Re: Shared libraries^Wmodules in Perl
by dragonchild (Archbishop) on Sep 12, 2005 at 19:04 UTC
    As halley stated, mod_perl does provide shared memory for modules loaded in the startup.pl. The way this works is that it's loaded and all the children get to share it. If they write to the shared memory, the shared space gets copied to that child, so it's a Copy-On-Write strategy. This also means that changes made by one child do not get propagated to other children.

    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

      This is different from the JVM stuff the OP mentioned...

      Starting with Java 1.5, its JVM supports the concept of "shared memory", which has nothing to do with sharing data between related programs, such as parent/child.

      What it does is that, when a JVM tries to load a module/class, Java will first check whether the same class/module has already been loaded by another JVM. If it is, instead of reload the class/module, the loaded one will be used/shared between JVM's.

        Wow. Yet another reason to completely avoid Java altogether. Just the security issues alone make this undesirable, let alone the synchronization, the memory dirtying, and the potential for deadlocking.

        Yes, I understand that this is only supported for a certain set of modules, presumably ones that have been "vetted" by some authoritative group. All this means is that there's another entry to hack Java applications by replacing one of these libraries with a nefarious version. And, before you say "That can't happen", the people who designed Windows weren't stupid ...


        My criteria for good software:
        1. Does it work?
        2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
        Just to notice, as I said in UPDATE2 of the main post, it does it only for some small set of core libraries.
        daniel

      Yes, but this only works for children of the same parent.

      When I say shared library, I mean the memory being shared by unrelated processes. For instance, perl script X uses A, perl script Y uses A, they run in different environments of the same machine (one in apache and the other in console, for instance), if A is shareable and script X run before, when script Y runs, A won't be loaded again.

      daniel
Re: Shared libraries^Wmodules in Perl
by halley (Prior) on Sep 12, 2005 at 18:48 UTC
    I'll link this reply to a previous thread discussing the theory behind a continuous session with: A Perl Daemon.

    The "mod_perl" facility for the Apache web server does support some of this notion, though how much it caches and how much it flushes per script, I don't really know.

    --
    [ e d @ h a l l e y . c c ]

Re: Shared libraries^Wmodules in Perl
by pg (Canon) on Sep 12, 2005 at 20:53 UTC

    The question is whether the Perl 6 guys want to pursuit this. It does sound to me like a great idea, but with a project, you always need to prioritize things. As you can see, I think Perl 6 development is under other pressures that are more important, in order to form the base of the language, as well as the VM.

    As whether it is getting difficult for Perl 6 to do this, comparing with Perl 5, my guess is not, and it is probably getting easier. With the VM concept being introduced, it become a perfect place to add this sort of control.

    Look at Java's experience, it should be something "addable" at a later stage.