Re: What's cooking in git.git (topics)

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jeff King <peff@...>
Cc: Junio C Hamano <gitster@...>, <git@...>
Date: Thursday, September 27, 2007 - 2:43 am

David Kastrup <dak@gnu.org> writes:


Ok, here is some suggestion:

Here is the inner loop for this stuff:

	for (i = 0; i < ssz; i++) {
		struct spanhash *s = &(src_count->data[i]);
		struct spanhash *d;
		unsigned dst_cnt, src_cnt;
		if (!s->cnt)
			continue;
		src_cnt = s->cnt;
		d = spanhash_find(dst_count, s->hashval);
		dst_cnt = d ? d->cnt : 0;
		if (src_cnt < dst_cnt) {
			la += dst_cnt - src_cnt;
			sc += src_cnt;
		}
		else
			sc += dst_cnt;
	}

Now here is how one could optimize the data structures: The hash
structures are with linear probing, and we try to find any hash
matches from source to destination.  If we sort all hashes indexed to
a given first hash bucket by their full hash value, then one could
basically use passes similar to list merges for figuring the 1:1
relations.  That cuts down the O(l n) cost (where n is the number of
elements and l their average run length) to O(n).

Of course, making l close to 1 by keeping the hash utilization
reasonably low is much simpler.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
What's cooking in git.git (topics), Junio C Hamano, (Thu Sep 6, 4:52 am)
What's cooking in git.git (topics), Junio C Hamano, (Fri Sep 14, 6:04 am)
What's cooking in git.git (topics), Junio C Hamano, (Wed Sep 26, 4:05 pm)
What's cooking in git.git (topics), Junio C Hamano, (Tue Oct 2, 1:53 am)
Re: What's cooking in git.git (topics), Daniel Barkalow, (Tue Oct 2, 1:00 pm)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Tue Oct 2, 8:52 am)
Re: What's cooking in git.git (topics), Steffen Prohaska, (Tue Oct 2, 2:44 am)
Re: What's cooking in git.git (topics), Matthieu Moy, (Tue Oct 2, 3:03 am)
Re: What's cooking in git.git (topics), Junio C Hamano, (Tue Oct 2, 3:21 am)
Re: What's cooking in git.git (topics), Matthieu Moy, (Tue Oct 2, 4:07 am)
Re: What's cooking in git.git (topics), Junio C Hamano, (Tue Oct 2, 1:44 pm)
Re: What's cooking in git.git (topics), Steven Grimm, (Tue Oct 2, 2:41 am)
Re: What's cooking in git.git (topics), Daniel Barkalow, (Thu Sep 27, 11:24 pm)
Re: What's cooking in git.git (topics), Jeff King, (Wed Sep 26, 10:36 pm)
Re: What's cooking in git.git (topics), Jeff King, (Tue Oct 2, 12:16 am)
Re: What's cooking in git.git (topics), Junio C Hamano, (Tue Oct 2, 1:01 am)
Re: What's cooking in git.git (topics), Jeff King, (Tue Oct 2, 1:08 am)
Re: What's cooking in git.git (topics), Jeff King, (Tue Oct 2, 1:13 am)
Re: What's cooking in git.git (topics), David Kastrup, (Thu Sep 27, 2:08 am)
Re: What's cooking in git.git (topics), Jeff King, (Thu Sep 27, 9:30 am)
Re: What's cooking in git.git (topics), David Kastrup, (Thu Sep 27, 2:43 am)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Wed Sep 26, 5:44 pm)
Re: What's cooking in git.git (topics), Tom Clarke, (Wed Sep 26, 5:53 pm)
Re: What's cooking in git.git (topics), Johannes Schindelin, (Fri Sep 14, 7:47 pm)
Re: What's cooking in git.git (topics), Carlos Rica, (Wed Sep 26, 5:07 pm)
Re: What's cooking in git.git (topics), Shawn O. Pearce, (Fri Sep 14, 2:30 pm)