git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Junio C Hamano <junkio@cox.net>
Cc: Fredrik Kuivinen <freku045@student.liu.se>, git@vger.kernel.org
Subject: Re: git-diff-tree -M performance regression in 'next'
Date: Sun, 12 Mar 2006 17:09:47 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0603121700410.3618@g5.osdl.org> (raw)
In-Reply-To: <7vwtezw4ye.fsf@assigned-by-dhcp.cox.net>



On Sun, 12 Mar 2006, Junio C Hamano wrote:
> 
> To reduce wasted memory, wait until the hash fills up more
> densely before we rehash.  This reduces the working set size a
> bit further.

Umm. Why do you rehash at all?

Just take the size of the "src" file as the initial hash size. 

Also, I think it is likely really wasteful to try to actually hash at 
_each_ character. Instead, let's say that the chunk-size is 8 bytes (like 
you do now), and let's say that you have a 32-bit good hash of those 8 
bytes. What you can do is:

 - for each 8 bytes in the source, hash those 8 bytes (not every byte)
 - for each byte in the other file, hash 8 next bytes. IF it matches a 
   hash in the source with a non-zero count, subtract the count for that 
   hash and move up by _eight_ characters! If it doesn't, add one to 
   "characters not matched" counter, and move up _one_ character, and try 
   again.

At the end of this, you have two counts: the count of characters that you 
couldn't match in the other file, and the count of 8-byte hash-chunks that 
you couldn't match in the first one. Use those two counts to decide if 
it's close or not.

Especially for good matches, this should basically cut your work into an 
eight of what you do now.

Actually, even for bad matches, you cut the first source overhead into one 
eight (the second file will obviously do the "update by 1 byte" most of 
the time).

Don't you think that would be as accurate as what you're doing now (it's 
the same basic notion, after all), and noticeably faster?

			Linus

  reply	other threads:[~2006-03-13  1:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-11 17:28 git-diff-tree -M performance regression in 'next' Fredrik Kuivinen
2006-03-12  3:10 ` Junio C Hamano
2006-03-12 12:28 ` Junio C Hamano
2006-03-12 17:00   ` Linus Torvalds
2006-03-12 19:34     ` Junio C Hamano
2006-03-13  0:42       ` Junio C Hamano
2006-03-13  1:09         ` Linus Torvalds [this message]
2006-03-13  1:22           ` Junio C Hamano
2006-03-13  1:39             ` Linus Torvalds
2006-03-13  1:29           ` Linus Torvalds
2006-03-13  1:31             ` Linus Torvalds
2006-03-13  2:29             ` Linus Torvalds
2006-03-13  2:53               ` Linus Torvalds
2006-03-13  4:14             ` Junio C Hamano
2006-03-14  2:55               ` Junio C Hamano
2006-03-14  3:47                 ` Linus Torvalds
2006-03-14 10:26                   ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0603121700410.3618@g5.osdl.org \
    --to=torvalds@osdl.org \
    --cc=freku045@student.liu.se \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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.
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 NNTP newsgroup(s).