* Sha1 lookup and GIT_USE_LOOKUP
@ 2011-06-08 18:31 Marc Pegon
2011-06-08 18:55 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Marc Pegon @ 2011-06-08 18:31 UTC (permalink / raw)
To: git
Hi,
I noticed in find_pack_entry_one the use of the environment variable
GIT_USE_LOOKUP, which does not seem to be used anywhere else in git or
even in the tests.
Obviously, it determines whether or not a simple binary search or the
sha1_entry_pos method (which is apparently some kind of improved
binary search) should be used to retrieve the offset of an object
(given its sha1) in a pack.
Since this environment variable is not set by default, git will always
use a simple binary search, won't it ?
Also, when searching for a sha1 given a sha1 prefix, among packed
objects, find_short_packed_object also does a simple binary search.
Wouldn't it be simpler to just use the sha1_entry_pos method ?
Thanks
--
Marc Pegon
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Sha1 lookup and GIT_USE_LOOKUP
2011-06-08 18:31 Sha1 lookup and GIT_USE_LOOKUP Marc Pegon
@ 2011-06-08 18:55 ` Junio C Hamano
2011-06-09 9:24 ` Marc Pegon
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2011-06-08 18:55 UTC (permalink / raw)
To: Marc Pegon; +Cc: git
Marc Pegon <pegon.marc@gmail.com> writes:
> Since this environment variable is not set by default, git will always
> use a simple binary search, won't it ?
Yes.
> Also, when searching for a sha1 given a sha1 prefix, among packed
> objects, find_short_packed_object also does a simple binary search.
> Wouldn't it be simpler to just use the sha1_entry_pos method ?
Unknown ;-).
The environment variable is there exactly for people like you who are
interested in finding out which one yields better performance by
benchmarking. Once we can get a convincing result, we can either
deprecate the more involved sha1_entry_pos() if it turns out to be not
worth it, or we can always use it if it turns out to be significantly
better.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Sha1 lookup and GIT_USE_LOOKUP
2011-06-08 18:55 ` Junio C Hamano
@ 2011-06-09 9:24 ` Marc Pegon
2011-06-09 22:51 ` Michael Schubert
0 siblings, 1 reply; 4+ messages in thread
From: Marc Pegon @ 2011-06-09 9:24 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Wed, Jun 8, 2011 at 8:55 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Marc Pegon <pegon.marc@gmail.com> writes:
>
>> Since this environment variable is not set by default, git will always
>> use a simple binary search, won't it ?
>
> Yes.
>
>> Also, when searching for a sha1 given a sha1 prefix, among packed
>> objects, find_short_packed_object also does a simple binary search.
>> Wouldn't it be simpler to just use the sha1_entry_pos method ?
>
> Unknown ;-).
>
> The environment variable is there exactly for people like you who are
> interested in finding out which one yields better performance by
> benchmarking. Once we can get a convincing result, we can either
> deprecate the more involved sha1_entry_pos() if it turns out to be not
> worth it, or we can always use it if it turns out to be significantly
> better.
Perhaps we could compare the two methods by counting for each one the
average number of iterations it takes to find an object in a pack.
But anyways, I guess GIT_USE_LOOKUP should also have an influence on
the method used to find an object given a sha1 prefix, and the code
that does a simple binary search should not be duplicated as it is
now, right ?
> Thanks.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Sha1 lookup and GIT_USE_LOOKUP
2011-06-09 9:24 ` Marc Pegon
@ 2011-06-09 22:51 ` Michael Schubert
0 siblings, 0 replies; 4+ messages in thread
From: Michael Schubert @ 2011-06-09 22:51 UTC (permalink / raw)
To: Marc Pegon; +Cc: Junio C Hamano, git
On 06/09/2011 11:24 AM, Marc Pegon wrote:
> On Wed, Jun 8, 2011 at 8:55 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Marc Pegon <pegon.marc@gmail.com> writes:
>>
>>> Since this environment variable is not set by default, git will always
>>> use a simple binary search, won't it ?
>>
>> Yes.
>>
>>> Also, when searching for a sha1 given a sha1 prefix, among packed
>>> objects, find_short_packed_object also does a simple binary search.
>>> Wouldn't it be simpler to just use the sha1_entry_pos method ?
>>
>> Unknown ;-).
>>
>> The environment variable is there exactly for people like you who are
>> interested in finding out which one yields better performance by
>> benchmarking. Once we can get a convincing result, we can either
>> deprecate the more involved sha1_entry_pos() if it turns out to be not
>> worth it, or we can always use it if it turns out to be significantly
>> better.
>
> Perhaps we could compare the two methods by counting for each one the
> average number of iterations it takes to find an object in a pack.
> But anyways, I guess GIT_USE_LOOKUP should also have an influence on
> the method used to find an object given a sha1 prefix, and the code
> that does a simple binary search should not be duplicated as it is
> now, right ?
The commit introducing sha1_entry_pos() comes with some reasoning:
628522
libgit2 dropped "old and boring binary search" some days ago:
dd453c
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-09 22:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-08 18:31 Sha1 lookup and GIT_USE_LOOKUP Marc Pegon
2011-06-08 18:55 ` Junio C Hamano
2011-06-09 9:24 ` Marc Pegon
2011-06-09 22:51 ` Michael Schubert
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).