Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Class::Std::Fast cache and threads

by Boldra (Deacon)
on Oct 13, 2010 at 15:35 UTC ( #865104=note: print w/replies, xml ) Need Help??


in reply to Re^2: Class::Std::Fast cache and threads
in thread Class::Std::Fast cache and threads

Definitely a good point. I haven't tested it myself, insteadI'm trusting the claims of the CSF author who says it's "an order of magnitude faster". You may have missed is that it's caching a blessed scalar ref, which means that on the next new call, it can just pop an item of the cache instead of blessing a new object. This is apparently where the speed saving comes from.

I'm also a bit stuck with the problem that the caching is set at import in about 20 SOAP::WSDL::XSD::Typelib::Builtin::* modules (and possibly other modules autogenerated by wsdl2perl). I'm sticking with my "caching is faster" excuse for now though - I'll switch to "I'm too lazy" when I get desperate :)

  • Comment on Re^3: Class::Std::Fast cache and threads

Replies are listed 'Best First'.
Re^4: Class::Std::Fast cache and threads
by BrowserUk (Pope) on Oct 13, 2010 at 15:52 UTC
    You may have missed is that it's caching a blessed scalar ref, which means that on the next new call, it can just pop an item of the cache instead of blessing a new object.

    Blessing a ref takes an infinitesimal amount of time. My benchmark:

    package STR; use Class::Std::Fast; ## cache => 1; package main; use Time::HiRes qw[ time ]; my $start = time; STR->new for 1 .. 1e6; printf "Took %.8f seconds\n", ( time - $start ) / 1e6; __END__ ## With caching c:\test>junk64 Took 0.00002447 seconds ## Without caching c:\test>junk64 Took 0.00002391 seconds

    And if you removed all the cache related conditionals, it would be quicker still.

    It would also avoid your original problem


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://865104]
help
Chatterbox?
[Corion]: ambrus: Yeah - we're in that situation too, except that there is no time to do the reorganizing :-/
[LanX]: ... so my boss started a project with the newest sun servers and invited the traders to come on weekend to test it... and they were so pleased, that they forced him to keep it in production...
[ambrus]: Corion: sure, this is the long-term plan. The short term is that I have to run this ungodly mess to get results from the new input data today.
[Corion]: ambrus: Most of our "automation" is tied to process exit codes and a shell pipeline :-\
[LanX]: ... a week later they realized that one of the databases - which recorded how much the other banks due to this bank - was not correctly plugged
[ambrus]: Corion: I have no problem with exit codes and shell pipeline. My problem is that the current process requires a lot of manual intervention from me, including editing the source codes.
[ambrus]: (Also a lot of manual intervention by two or three other co-workers, who do other parts of the process.)
[ambrus]: Some of the manual part is unavoidable, but not all.
[choroba]: LanX was there a way to recover the numbers from the remaining information?
[Corion]: LanX: Ow ;)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2017-03-29 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.