threads / patch / 24485

patch, 2 partsmake git installation footprint smaller

Subject: [PATCH 0/2] make git installation footprint smaller

## tl;dr

6 messages between Jul 23, 2010 and Jul 24, 2010. Diffs are folded; open one to read it.

replies: 5people: 3as markdown or json

Brandon Casey· Jul 23, 2010, 17:50 UTC · lore

Ever wonder where that extra 5MB of disk space went that you thought you had? Well, it turns out that git isn't being quite as space-efficient as it could be. Some files that could be installed as links are instead being installed as full copies of the original.

With these two patches, we shrink the installation footprint of git by making hard or symbolic links for non-builtin programs and for those binaries installed in the bin directory. We already do this for binaries installed in libexec. This can reduce the size of a git installation on the order of 10-30%. Probably about 5-10MB. Whoopee!!!

Enjoy.
Brandon Casey (2):
  Makefile: link builtins residing in bin directory to main git binary
    too
  Makefile: make hard/symbolic links for non-builtins too
 Makefile |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
-- 
1.7.2
Brandon Casey· Jul 23, 2010, 17:50 UTC · re: Brandon Casey · lore

[PATCH 1/2] Makefile: link builtins residing in bin directory to main git binary too

From: Brandon Casey <drafnel@gmail.com>

To conserve space/improve file caching we try to make hard or symbolic links from each builtin program to the main git executable rather than having each be a complete duplicate copy of it. We weren't doing this for the builtin programs residing in the bin directory though. So, let's do so.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 Makefile |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Show changes to Makefile +6 −0
diff --git a/Makefile b/Makefile
index bc3c570..d725c15 100644
--- a/Makefile
+++ b/Makefile
@@ -2079,6 +2079,12 @@ endif
 		test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
 		ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
 		cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \
+	for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
+		$(RM) "$$bindir/$$p" && \
+		ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
+		ln -s "git$X" "$$bindir/$$p" 2>/dev/null || \
+		cp "$$bindir/git$X" "$$bindir/$$p" || exit; \
+	done && \
 	for p in $(BUILT_INS); do \
 		$(RM) "$$execdir/$$p" && \
 		ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \
-- 
1.7.2
Brandon Casey· Jul 23, 2010, 17:50 UTC · re: Brandon Casey · lore

[PATCH 2/2] Makefile: make hard/symbolic links for non-builtins too

From: Brandon Casey <drafnel@gmail.com>

To conserve space/improve file caching we try to make hard or symbolic links from each builtin program to the main git executable rather than having each be a complete duplicate copy of it. We weren't doing this for the non-builtin programs though. So, just because we can, and because it's easy, and for completeness sake, let's do it.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
---
 Makefile |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
Show changes to Makefile +6 −3
diff --git a/Makefile b/Makefile
index d725c15..17c9130 100644
--- a/Makefile
+++ b/Makefile
@@ -2075,10 +2075,13 @@ endif
 	bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
 	execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
 	{ test "$$bindir/" = "$$execdir/" || \
-		{ $(RM) "$$execdir/git$X" && \
+	  for p in git$X $(filter $(install_bindir_programs),$(ALL_PROGRAMS)); do \
+		$(RM) "$$execdir/$$p" && \
 		test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
-		ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \
-		cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \
+		ln "$$bindir/$$p" "$$execdir/$$p" 2>/dev/null || \
+		cp "$$bindir/$$p" "$$execdir/$$p" || exit; \
+	  done; \
+	} && \
 	for p in $(filter $(install_bindir_programs),$(BUILT_INS)); do \
 		$(RM) "$$bindir/$$p" && \
 		ln "$$bindir/git$X" "$$bindir/$$p" 2>/dev/null || \
-- 
1.7.2
A Large Angry SCM· Jul 23, 2010, 18:12 UTC · re: Brandon Casey · lore

Re: [PATCH 0/2] make git installation footprint smaller

On 07/23/2010 01:50 PM, Brandon Casey wrote:
Show 21 quoted lines
> Ever wonder where that extra 5MB of disk space went that you thought you
> had?  Well, it turns out that git isn't being quite as space-efficient as
> it could be.  Some files that could be installed as links are instead being
> installed as full copies of the original.
>
> With these two patches, we shrink the installation footprint of git by
> making hard or symbolic links for non-builtin programs and for those binaries
> installed in the bin directory.  We already do this for binaries installed
> in libexec.  This can reduce the size of a git installation on the order of
> 10-30%.  Probably about 5-10MB.  Whoopee!!!
>
> Enjoy.
>
> Brandon Casey (2):
>    Makefile: link builtins residing in bin directory to main git binary
>      too
>    Makefile: make hard/symbolic links for non-builtins too
>
>   Makefile |   15 ++++++++++++---
>   1 files changed, 12 insertions(+), 3 deletions(-)
>
What happens when bindir and execdir are the same?
Brandon Casey· Jul 23, 2010, 18:17 UTC · re: A Large Angry SCM · lore

Re: [PATCH 0/2] make git installation footprint smaller

A Large Angry SCM wrote:
Show 11 quoted lines
> On 07/23/2010 01:50 PM, Brandon Casey wrote:
>> Brandon Casey (2):
>>    Makefile: link builtins residing in bin directory to main git binary
>>      too
>>    Makefile: make hard/symbolic links for non-builtins too
>>
>>   Makefile |   15 ++++++++++++---
>>   1 files changed, 12 insertions(+), 3 deletions(-)
>>
> 
> What happens when bindir and execdir are the same?

Nothing. See the second patch "make hard/symbolic links for non-builtins too". We already handled this case.

Jonathan Nieder· Jul 24, 2010, 02:31 UTC · re: Brandon Casey · lore

Re: [PATCH 0/2] make git installation footprint smaller

Brandon Casey wrote:
> Brandon Casey (2):
>   Makefile: link builtins residing in bin directory to main git binary
>     too
>   Makefile: make hard/symbolic links for non-builtins too
So in the end, the hardlink-forming step has four steps:
1. (if bindir != libexecdir and NO_CROSS_DIRECTORY_HARDLINKS is unset)
   Files in libexecdir with cousins in bindir are replaced by
   hardlinks to their cousins. (patch 2)
2. Any builtins in bindir are replaced by
   hardlinks, symlinks, or copies of git.
3. Any builtins in libexecdir are replaced by
   hardlinks, symlinks, or copies of git.
4. git-remote-{ftp,http, etc} are replaced by
   hardlinks, symlinks, or of git-remote-http.
Looks good to me.

Thanks for the pleasant read, Jonathan

← back to recent threads