develooper Front page | perl.perl5.porters | Postings from April 2007

Re: Performance problems with Hash::Util::FieldHash

Thread Previous | Thread Next
From:
Anno Siegel
Date:
April 21, 2007 13:34
Subject:
Re: Performance problems with Hash::Util::FieldHash
Message ID:
FB6C5DD1-ADEF-4898-9017-43C5B45273E9@mailbox.tu-berlin.de
On 19.04.2007, at 22:02, Jerry D. Hedden wrote:

[possible speed hack]

> That sounds interesting.  Again, perhaps it could be added
> as an optional feature.  (Would you mind sending me the code
> so I could marvel at it?  Thanks.)

Right.  Here is a version of HUF that optionally applies the technique.
You need a reasonably recent bleadperl for the build.  Then

     cd bench_Hedden
     bleadperl -Mblib set.pl
     # etc.

The (modified) base.pl shows how to create a FieldHash in
"fast" mode (Hash::Util::FieldHash::_fieldhash \ my %h, 2).
Class FieldHash_f in base.pl does this.  Good job, your little
benchmark kit.  It ran immediately and was straightforward
to modify.  Nice tight code.

On my machine, FieldHash_f still falls short of Refaddr by -10%
in set actions, but is much better than the -40% of the current
version.  No effect on get (expected), where it's equal to Refaddr.

I am still undecided if the change is worth the complication and
potentially unsafe operation that comes with it.  On the one
hand, I'm not quite sure how unsafe it actually is.  Under certain
conditions, object registry can be bypassed.  On the other hand,
I'd like to run benchmarks that show the impact on one or two
more typical classes.  I expect it to be rather small.  Thanks to
your initiative I have now a version of HUF that allows these
tests.

Regards, Anno


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About