Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: exists *{$glob} ? (+)

by ikegami (Patriarch)
on Sep 09, 2004 at 07:50 UTC ( [id://389577]=note: print w/replies, xml ) Need Help??


in reply to exists *{$glob} ? (+)

Also, has anyone ever written a program (in any language, but particularly Perl) that used more than 4000 classes, or a million instances* of a given class?

yes, just now, just so I could say I did.

>perl -le "push(@a, bless({}, sprintf('MyClass%04d',$i++))) foreach (1..4001); print(scalar(@a));" 4001 >perl -le "push(@a, bless({}, 'MyClass')) foreach (1..1000001); print(scalar(@a));" 1000001

Check the two snippets called "Symtab Exploration" in ikegami's scratchpad for code looking at the symbol table. Combine that code with *name{TYPE} to look for things other than package names.

Replies are listed 'Best First'.
Re^2: exists *{$glob} ? (+)
by BrowserUk (Patriarch) on Sep 09, 2004 at 08:41 UTC

    I guess I could requalify the question with something like "Has anyone ever written a useful, practical, program that used more than 4000 concurrent classes, or 1 million concurrent instances of any given class", but then you could say that your snippets were useful because they proved it could be done :)

    An idea I am playing with uses a 32-bit value as a handle to object instances. That dword will indicate both the class, and the instance of that class. There are various ways that I could subdivide the bits. 64K instances x 64k classes. 16M x 256 etc. Looking at the possible splits, I've pretty much concluded that 12-bits for classes and 20-bits for instances is a reasonable split for most purposes, but was trying to elicit a responcse of "Yeah! My Finite Element Analysis (or Ray Tracing) program routinely has over a million concurrent instances of xxx class" or similar.

    In theory, and probably practice, it would be possible to define the split at compile time. Given most current processors are 32-bit/4GB max memory, and each instance of a class is always going to be more than 1 byte, it is unlikely that any single program will create more that 2**32 concurrent instances of all classes. If, as, and when the program was ever moved to a 64-bit platform, 4GB instances of 4GB classes will suffice for most purposes.

    So, it is just a case of trying to decide what would be the most suitable default split for the 32-bits?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://389577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-26 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found