git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/WIP 0/8] Make git-am a builtin
@ 2015-05-27 13:33 Paul Tan
  2015-05-27 13:33 ` [PATCH/WIP 1/8] wrapper: implement xopen() Paul Tan
                   ` (7 more replies)
  0 siblings, 8 replies; 24+ messages in thread
From: Paul Tan @ 2015-05-27 13:33 UTC (permalink / raw)
  To: git; +Cc: Stefan Beller, Johannes Schindelin, Paul Tan

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2015-06-04 12:05 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-27 13:33 [PATCH/WIP 0/8] Make git-am a builtin Paul Tan
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

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).