develooper Front page | perl.perl5.porters | Postings from December 2016

Re: Hash change... Hybrid OAATH variant for short keys, Siphash 1-3for longer keys

Thread Previous
From:
Dave Mitchell
Date:
December 7, 2016 14:50
Subject:
Re: Hash change... Hybrid OAATH variant for short keys, Siphash 1-3for longer keys
Message ID:
20161207145021.GP23566@iabyn.com
On Wed, Dec 07, 2016 at 12:41:34PM +0000, Dave Mitchell wrote:
> The code is run a loop, so what's left over at the end of one iteration
> can indeed affect the next. Using exists ensures that neither key nor
> value is added to the hash, and is instead only looked up.

and because it still confuses me (and wrote the damned thing), I've just
added these comments at the top of t/perf/benchmarks to (hopefully) help
clarify:

# Note: for the cachegrind variant, an entry like
#    'foo::bar' => {
#     setup   => 'SETUP',
#     code    => 'CODE',
#   }
# creates two temporary perl sources looking like:
#
#        package foo::bar;
#        BEGIN { srand(0) }
#        SETUP;
#        for my $__loop__ (1..$ARGV[0]) {
#            1;
#        }
#
# and as above, but with the '1;' in the loop  body replaced with:
#
#            CODE;
#
# It then pipes each of the two sources into
#
#     PERL_HASH_SEED=0 valgrind [options] someperl [options] - N
#
# where N is set to 10 and then 20.
#
# It then uses the result of those four cachegrind runs to subtract out
# the perl startup and loop overheads. So only what's in SETUP and CODE
# can affect the benchmark, and if the loop happens to leave some state
# changed (such as storing a value in a hash), then the final benchmark
# timing is the result of running CODE with the hash entry populated
# rather than empty.


-- 
The optimist believes that he lives in the best of all possible worlds.
As does the pessimist.

Thread Previous


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