git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Baudis <pasky@suse.cz>
To: Andreas Ericsson <ae@op5.se>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] C implementation of the 'git' program.
Date: Fri, 11 Nov 2005 00:37:51 +0100	[thread overview]
Message-ID: <20051110233751.GD30496@pasky.or.cz> (raw)
In-Reply-To: <4373CEA8.1020900@op5.se>

Dear diary, on Thu, Nov 10, 2005 at 11:50:16PM CET, I got a letter
where Andreas Ericsson <ae@op5.se> said that...
> Linus Torvalds wrote:
> >
> >And the performance difference does seem to be quite noticeable too..
> >
> 
> Yes. I was quite astonished when I noticed first, thinking the shell 
> kept the parsed script in cache or some such. Apparently it doesn't.

The bulk of the time is likely not spent parsing, but executing
subprocesses, that's hideously expensive. Just for fun, you can try to
measure the improvement when you remove the $(dirname "$0"). Here, for
1000 tries it's roughly 9s normal, 7s without dirname and 3s direct
invocation, which seems to give you _very roughly_ 2s per subprocess,
and 2s other shell overhead, which is unusually right.

Actually, I can bring the git.sh runtime from 7s to 4.7s:

-       case "$cmd" in
-       -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+       if [[ "$cmd" = "-v" ||
+             "$cmd" = "--v" ||
+             "$cmd" = "--ve" ||
+             "$cmd" = "--ver" ||
+             "$cmd" = "--vers" ||
+             "$cmd" = "--versi" ||
+             "$cmd" = "--versio" ||
+             "$cmd" = "--version" ]]; then
                echo "git version @@GIT_VERSION@@"
                exit 0 ;;
-       esac
+       fi
				(whitespace-mangled)

Well, subconsciously I never really trusted this case thing. ;-)

This leaves ~ 1.7s to other shell overhead and execve() (the main
command call is without the fork(), while $(dirname) fork()s).

> >>The location of the GIT_LIB can be obtained by running
> >>
> >>	git --lib
> >
> >
> >I think this might be a bit ambiguous. When I see "GIT_LIB", to me it 
> >implies traditional libraries (ie a "libgit.a" kind of thing), not the 
> >kind of "git executable plugin" directory.
> >
> >So I'd suggest renaming "--lib" and "GIT_LIB" to be more of a "--libexec" 
> >kind of flavor, if only to avoid that confusion.
> 
> 
> Someone said libexec was moving out (of Linux, at least), so I thought 
> I'd better avoid that. Perhaps GIT_LIBDIR?

This may not necessarily have anything in common with the actual
directory name. I prefer libexec too (but personally don't care too
much).

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.

  reply	other threads:[~2005-11-10 23:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-10 18:26 [PATCH] C implementation of the 'git' program Andreas Ericsson
2005-11-10 19:41 ` Linus Torvalds
2005-11-10 22:50   ` Andreas Ericsson
2005-11-10 23:37     ` Petr Baudis [this message]
2005-11-11 19:31     ` Junio C Hamano
2005-11-11  6:58 ` Raja R Harinath
2005-11-11  7:40   ` Junio C Hamano
2005-11-11 12:04     ` Andreas Ericsson
2005-11-11 19:37       ` 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=20051110233751.GD30496@pasky.or.cz \
    --to=pasky@suse.cz \
    --cc=ae@op5.se \
    --cc=git@vger.kernel.org \
    /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).