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

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

Thread Previous | Thread Next
Anno Siegel
April 21, 2007 13:34
Re: Performance problems with Hash::Util::FieldHash
Message ID:
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
     # etc.

The (modified) shows how to create a FieldHash in
"fast" mode (Hash::Util::FieldHash::_fieldhash \ my %h, 2).
Class FieldHash_f in 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

Regards, Anno

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About