From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Stefan Beller <sbeller@google.com>,
gitster@pobox.com, git@vger.kernel.org, jrnieder@gmail.com
Subject: Re: [PATCH 2/2] diff.c: get rid of duplicate implementation
Date: Mon, 30 Oct 2017 12:07:10 -0700 [thread overview]
Message-ID: <20171030190710.w7pyokbfxzkjdqcx@sigill.intra.peff.net> (raw)
In-Reply-To: <20171030175941.tbjlfp72txgod22x@sigill.intra.peff.net>
On Mon, Oct 30, 2017 at 10:59:41AM -0700, Jeff King wrote:
> > There's also https://www.strchr.com/hash_functions, which lists DJB2
> > as Bernstein. Both functions rank somewhere in the middle of that list.
>
> FWIW, I did some experiments with Murmur3 and SipHash a while back, but
> I don't think I came up with anything faster than the existing code.
> OTOH, moving to SipHash gives us the ability to randomize the hashes,
> which can resist some DoS attacks (although as I've said before,
> computing arbitrary diffs for untrusted strangers is pretty much a
> DoS-in-a-box).
By the way, one of the things that complicates plugging new functions
into xdiff's hashing is that xdl_hash_record() simultaneously computes
the hash _and_ finds the end-of-line marker.
So the "siphash is only 10% slower" number I showed came with quite a
few contortions to do both. Here it is compared to a more naive
application of the siphash code (i.e., memchr to find end-of-line, and
then feed the resulting bytes to siphash):
Test origin HEAD^ jk/xdl-siphash-wip
-------------------------------------------------------------------------------------------------------
4000.1: log -3000 (baseline) 0.05(0.05+0.00) 0.05(0.05+0.00) +0.0% 0.05(0.05+0.00) +0.0%
4000.2: log --raw -3000 (tree-only) 0.31(0.27+0.03) 0.31(0.27+0.03) +0.0% 0.31(0.27+0.03) +0.0%
4000.3: log -p -3000 (Myers) 2.06(2.01+0.05) 2.30(2.21+0.09) +11.7% 2.96(2.91+0.04) +43.7%
4000.4: log -p -3000 --histogram 2.44(2.38+0.06) 2.67(2.60+0.07) +9.4% 3.32(3.26+0.06) +36.1%
4000.5: log -p -3000 --patience 2.57(2.47+0.09) 2.90(2.82+0.08) +12.8% 3.48(3.43+0.05) +35.4%
There "origin" is the existing djb hash, "HEAD^" is the complicated
"fast" siphash (which I very well may have screwed up), and the final is
the more naive version, which is quite a bit slower.
-Peff
next prev parent reply other threads:[~2017-10-30 19:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 18:59 [PATCH 0/4] (x)diff cleanup: remove duplicate code Stefan Beller
2017-10-24 18:59 ` [PATCH 1/4] hashmap: introduce memhash_feed to access the internals of FNV-1 hash Stefan Beller
2017-10-24 20:23 ` René Scharfe
2017-10-24 20:48 ` Stefan Beller
2017-10-24 18:59 ` [PATCH 2/4] xdiff-interface: export comparing and hashing strings Stefan Beller
2017-10-24 20:23 ` René Scharfe
2017-10-24 20:42 ` Stefan Beller
2017-10-26 17:03 ` René Scharfe
2017-10-24 18:59 ` [PATCH 3/4] xdiff: use stronger hash function internally Stefan Beller
2017-10-24 20:23 ` René Scharfe
2017-10-24 20:46 ` Stefan Beller
2017-10-24 23:04 ` Jonathan Nieder
2017-10-24 18:59 ` [PATCH 4/4] diff.c: get rid of duplicate implementation Stefan Beller
2017-10-24 19:02 ` [PATCH 0/4] (x)diff cleanup: remove duplicate code Stefan Beller
2017-10-24 23:42 ` [PATCHv2 0/2] " Stefan Beller
2017-10-24 23:42 ` [PATCH 1/2] xdiff-interface: export comparing and hashing strings Stefan Beller
2017-10-25 4:26 ` Eric Sunshine
2017-10-24 23:42 ` [PATCH 2/2] diff.c: get rid of duplicate implementation Stefan Beller
2017-10-25 5:11 ` [PATCHv2 0/2] (x)diff cleanup: remove duplicate code Junio C Hamano
2017-10-25 18:47 ` Stefan Beller
2017-10-25 18:49 ` [PATCHv3 " Stefan Beller
2017-10-25 18:49 ` [PATCH 1/2] xdiff-interface: export comparing and hashing strings Stefan Beller
2017-10-26 17:12 ` René Scharfe
2017-10-27 7:12 ` Junio C Hamano
2017-10-27 17:15 ` Stefan Beller
2017-10-25 18:49 ` [PATCH 2/2] diff.c: get rid of duplicate implementation Stefan Beller
2017-10-26 2:23 ` Junio C Hamano
2017-10-26 17:43 ` René Scharfe
2017-10-30 17:59 ` Jeff King
2017-10-30 19:07 ` Jeff King [this message]
2017-10-24 23:45 ` [PATCH 1/5] fnv: migrate code from hashmap to fnv Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171030190710.w7pyokbfxzkjdqcx@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=l.s.r@web.de \
--cc=sbeller@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).