Re: [PATCH] Introduce experimental remote object access mode
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 11, 2014, 19:29 UTC
- Message-ID
- <xmqqppmtphx0.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <CAJo=hJsO=FBkiOo5fuPbToxE1SR3Lh8oim0eTAR6bH1a-TcdPA@mail.gmail.com>
Shawn Pearce <spearce@spearce.org> writes:
> Why would you do this? Perhaps you need more time in your day > to consume tea or coffee. Set GIT_RTT and enjoy a beverage.
So the conclusion is that it is not practical to do a lazy fetch if it is done extremely naively at "we want this object --- wait a bit and we'll give you" level?
I am wondering if we can do a bit better, like "we want this object --- wait a bit, ah that's a commit, so it is likely that you may want the trees and blobs associated with it, too, if not right now but in a near future, let me push a pack that holds them to you"?
Show 57 quoted lines
>
> So-not-signed-off-by: this author or anyone else
> ---
>
> :-)
>
> sha1_file.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/sha1_file.c b/sha1_file.c
> index 6e8c05d..9bdcbc3 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -38,6 +38,7 @@ const unsigned char null_sha1[20];
>
> static const char *no_log_pack_access = "no_log_pack_access";
> static const char *log_pack_access;
> +static useconds_t rtt;
>
> /*
> * This is meant to hold a *small* number of objects that you would
> @@ -436,9 +437,20 @@ void prepare_alt_odb(void)
> read_info_alternates(get_object_directory(), 0);
> }
>
> +static void apply_rtt()
> +{
> + if (!rtt) {
> + char *rtt_str = getenv("GIT_RTT");
> + rtt = rtt_str ? strtoul(rtt_str, NULL, 10) * 1000 : 1;
> + }
> + if (rtt > 1)
> + usleep(rtt);
> +}
> +
> static int has_loose_object_local(const unsigned char *sha1)
> {
> char *name = sha1_file_name(sha1);
> + apply_rtt();
> return !access(name, F_OK);
> }
>
> @@ -1303,6 +1315,7 @@ void prepare_packed_git(void)
>
> if (prepare_packed_git_run_once)
> return;
> +
> prepare_packed_git_one(get_object_directory(), 1);
> prepare_alt_odb();
> for (alt = alt_odb_list; alt; alt = alt->next) {
> @@ -1439,6 +1452,7 @@ static int open_sha1_file(const unsigned char *sha1)
> struct alternate_object_database *alt;
>
> fd = git_open_noatime(name);
> + apply_rtt();
> if (fd >= 0)
> return fd;