git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Paul Tan <pyokagan@gmail.com>
To: git@vger.kernel.org
Cc: Stefan Beller <sbeller@google.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Paul Tan <pyokagan@gmail.com>
Subject: [PATCH/WIP 0/8] Make git-am a builtin
Date: Wed, 27 May 2015 21:33:30 +0800	[thread overview]
Message-ID: <1432733618-25629-1-git-send-email-pyokagan@gmail.com> (raw)

git-am is a commonly used command for applying a series of patches from a
mailbox to the current branch. Currently, it is implemented by the shell script
git-am.sh. However, compared to C, shell scripts have certain deficiencies:
they need to spawn a lot of processes, introduce a lot of dependencies and
cannot take advantage of git's internal caches.

This WIP patch series rewrites git-am.sh into optimized C builtin/am.c. It is
based on my finished prototype of the rewrite[1], and over the next 5 weeks I
will be cutting out small patches from the prototype to make it easier to
review and refine the patch series.

This is part of my GSoC project to rewrite git-pull.sh into git-am.sh into C
builtins[2].

A small benchmark that applies 50 patches[3]:

	#!/bin/sh
	git init &&
	echo initial >file &&
	git add file &&
	git commit -m initial &&
	git branch before-am &&
	for x in $(seq 50)
	do
	    echo $x >>file &&
	    git commit -a -m $x
	done &&
	git format-patch --stdout before-am.. >patches &&
	git checkout before-am &&
	time git patches >/dev/null

I ran this benchmark on my *Linux* system.

Timings for git on master:

1.40s, 1.42s, 1.25s, 1.32s, 1.10s. Avg: ~1.30s

Timings for git on master + this patch series applied:

0.24s, 0.22s, 0.22s, 0.19s, 0.25s. Avg: ~0.22s

This is around a 6x speedup. It's not because this patch series does less than
git-am.sh -- similar speedups can be observed with the prototype, which passes
the test suite[4].

(Sorry for leaving the other reviews hanging. I was too preoccupied with the
git-am rewrite, and was afraid of forgetting important details should I context
switch. Now that the prototype is finished I can deal with the other patch
series'.)

[1] https://github.com/pyokagan/git/compare/master...pyokagan:pt/ref-builtin-am
[2] https://gist.github.com/pyokagan/1b7b0d1f4dab6ba3cef1
[3] Since a 56-patch series was posted recently ;-)
[4] The subset of the test suite that calls git-rebase and git-am.

Paul Tan (8):
  wrapper: implement xopen()
  wrapper: implement xfopen()
  am: implement patch queue mechanism
  am: split out mbox/maildir patches with git-mailsplit
  am: detect mbox patches
  am: extract patch, message and authorship with git-mailinfo
  am: apply patch with git-apply
  am: commit applied patch

 Makefile          |   2 +-
 builtin.h         |   1 +
 builtin/am.c      | 687 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 git-compat-util.h |   2 +
 git.c             |   1 +
 wrapper.c         |  37 +++
 6 files changed, 729 insertions(+), 1 deletion(-)
 create mode 100644 builtin/am.c

-- 
2.1.4

             reply	other threads:[~2015-05-27 13:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27 13:33 Paul Tan [this message]
2015-05-27 13:33 ` [PATCH/WIP 1/8] wrapper: implement xopen() Paul Tan
2015-05-27 17:52   ` Stefan Beller
2015-05-27 19:03   ` Torsten Bögershausen
2015-05-27 21:53     ` Jeff King
2015-06-03  8:16       ` Paul Tan
2015-06-04 12:05     ` Paul Tan
2015-05-27 13:33 ` [PATCH/WIP 2/8] wrapper: implement xfopen() Paul Tan
2015-05-27 21:55   ` Jeff King
2015-05-27 13:33 ` [PATCH/WIP 3/8] am: implement patch queue mechanism Paul Tan
2015-05-27 20:38   ` Junio C Hamano
2015-05-27 13:33 ` [PATCH/WIP 4/8] am: split out mbox/maildir patches with git-mailsplit Paul Tan
2015-05-28 23:05   ` Eric Sunshine
2015-06-02 14:27     ` Paul Tan
2015-05-27 13:33 ` [PATCH/WIP 5/8] am: detect mbox patches Paul Tan
2015-05-31 17:16   ` Eric Sunshine
2015-05-27 13:33 ` [PATCH/WIP 6/8] am: extract patch, message and authorship with git-mailinfo Paul Tan
2015-05-27 20:44   ` Junio C Hamano
2015-05-27 22:13     ` Jeff King
2015-06-03  7:56     ` Paul Tan
2015-05-27 22:13   ` Junio C Hamano
2015-06-03  7:57     ` Paul Tan
2015-05-27 13:33 ` [PATCH/WIP 7/8] am: apply patch with git-apply Paul Tan
2015-05-27 13:33 ` [PATCH/WIP 8/8] am: commit applied patch Paul Tan

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432733618-25629-1-git-send-email-pyokagan@gmail.com \
    --to=pyokagan@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=sbeller@google.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).