git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: git@vger.kernel.org, j6t@kdbg.org, kusmabite@gmail.com,
	mlevedahl@gmail.com, ramsay@ramsay1.demon.co.uk,
	sunshine@sunshineco.com
Subject: Re: [PATCH 2/2] optimize set_shared_perm()
Date: Fri, 29 Mar 2013 14:20:27 -0700	[thread overview]
Message-ID: <7vli95nbs4.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <201303251657.57222.tboegi@web.de> ("Torsten =?utf-8?Q?B?= =?utf-8?Q?=C3=B6gershausen=22's?= message of "Mon, 25 Mar 2013 16:57:56 +0100")

Torsten Bögershausen <tboegi@web.de> writes:

>   optimize set_shared_perm() in path.c:
>
>   - sometimes the chown() function is called even when not needed.
>     (This can be provoced by running t1301, and adding some debug code)
>
>     Save a chmod from 400 to 400, or from 600->600 on these files:
>     .git/info/refs+
>     .git/objects/info/packs+
>
>     Save chmod on directories from 2770 to 2770:
>     .git/refs
>     .git/refs/heads
>     .git/refs/tags
>
>   - as all callers use mode == 0 when caling set_shared_perm(),
>     the function can be simplified.
>   - all callers use the macro adjust_shared_perm(path) from cache.h
>     Convert adjust_shared_perm() from a macro into a function prototype

The last two points can become a separate "preparation" step.  The
result would be easier to read.

Your updated adjust_shared_perm() does not begin with:

	if (!shared_repository)
        	return 0;

as the original, but it always first calls to get_st_mode_bits()
which makes a call to lstat(2).

That smells like a huge regression for !shared_repository case,
unless you have updated the existing callers of adjust_shared_perm()
not to call it when !shared_repository.

> diff --git a/path.c b/path.c
> index 2fdccc2..4bc918a 100644
> --- a/path.c
> +++ b/path.c
> @@ -1,14 +1,5 @@
>  /*
> - * I'm tired of doing "vsnprintf()" etc just to open a
> - * file, so here's a "return static buffer with printf"
> - * interface for paths.
> - *
> - * It's obviously not thread-safe. Sue me. But it's quite
> - * useful for doing things like
> - *
> - *   f = open(mkpath("%s/%s.git", base, name), O_RDONLY);
> - *
> - * which is what it's designed for.
> + * Different utilitiy functions for path and path names
>   */

Removing the stale "I'm tired of" is good; you do not have to move
it anywhere.  A single-liner

	/* Utilities for paths and pathnames */

should suffice.

Will discard this step (but will keep PATCH 1/2).

  reply	other threads:[~2013-03-29 21:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 15:57 [PATCH 2/2] optimize set_shared_perm() Torsten Bögershausen
2013-03-29 21:20 ` Junio C Hamano [this message]
2013-03-30  9:53   ` Torsten Bögershausen

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=7vli95nbs4.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=kusmabite@gmail.com \
    --cc=mlevedahl@gmail.com \
    --cc=ramsay@ramsay1.demon.co.uk \
    --cc=sunshine@sunshineco.com \
    --cc=tboegi@web.de \
    /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).