[Pkg-golang-commits] [golang] 05/07: backport two patches to improve archive/tar performance

Michael Stapelberg michael at stapelberg.de
Mon Jul 7 06:52:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

stapelberg pushed a commit to branch debian-sid
in repository golang.

commit 54e3c6fc82b4e59189ca6fa38547eb0f6d9034cc
Author: Michael Stapelberg <stapelberg at debian.org>
Date:   Thu Jul 3 23:33:51 2014 +0200

    backport two patches to improve archive/tar performance
---
 debian/changelog                                   |  5 ++-
 ...tar-reuse-temporary-buffer-in-writeHeader.patch | 33 +++++++++++++++++++
 ...-tar-reuse-temporary-buffer-in-readHeader.patch | 38 ++++++++++++++++++++++
 debian/patches/series                              |  2 ++
 4 files changed, 77 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 34b3dc0..8ce5e58 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,8 +7,11 @@ golang (2:1.3-2) unstable; urgency=medium
     deprecation warning about flet in the emacs part of golang-mode
     (Closes: #753607)
   * Migrate to emacsen >2 (Closes: #753607)
+  * Backport two patches to improve archive/tar performance (for docker):
+    debian/patches/0002-archive-tar-reuse-temporary-buffer-in-writeHeader.patch
+    debian/patches/0003-archive-tar-reuse-temporary-buffer-in-readHeader.patch
 
- -- Michael Stapelberg <stapelberg at debian.org>  Thu, 03 Jul 2014 19:08:34 +0200
+ -- Michael Stapelberg <stapelberg at debian.org>  Thu, 03 Jul 2014 23:33:46 +0200
 
 golang (2:1.3-1) unstable; urgency=medium
 
diff --git a/debian/patches/0002-archive-tar-reuse-temporary-buffer-in-writeHeader.patch b/debian/patches/0002-archive-tar-reuse-temporary-buffer-in-writeHeader.patch
new file mode 100644
index 0000000..bd30f92
--- /dev/null
+++ b/debian/patches/0002-archive-tar-reuse-temporary-buffer-in-writeHeader.patch
@@ -0,0 +1,33 @@
+Description: archive/tar: reuse temporary buffer in writeHeader
+Author: Cristian Staretu <unclejacksons at gmail.com>
+Last-Update: 2014-07-03
+Forwarded: not-needed
+Origin: vendor, https://code.google.com/p/go/source/detail?r=837348e418f33fc7a242f56dbe2feff829532526#
+
+---
+
+diff -r c5f72a685e25 -r 837348e418f3 src/pkg/archive/tar/writer.go
+--- a/src/pkg/archive/tar/writer.go	Wed Jul 02 15:28:57 2014 -0700
++++ b/src/pkg/archive/tar/writer.go	Thu Jul 03 09:40:53 2014 +1000
+@@ -37,8 +37,9 @@
+ 	nb         int64 // number of unwritten bytes for current file entry
+ 	pad        int64 // amount of padding to write after current file entry
+ 	closed     bool
+-	usedBinary bool // whether the binary numeric field extension was used
+-	preferPax  bool // use pax header instead of binary numeric header
++	usedBinary bool            // whether the binary numeric field extension was used
++	preferPax  bool            // use pax header instead of binary numeric header
++	hdrBuff    [blockSize]byte // buffer to use in writeHeader
+ }
+ 
+ // NewWriter creates a new Writer writing to w.
+@@ -160,7 +161,8 @@
+ 	// subsecond time resolution, but for now let's just capture
+ 	// too long fields or non ascii characters
+ 
+-	header := make([]byte, blockSize)
++	header := tw.hdrBuff[:]
++	copy(header, zeroBlock)
+ 	s := slicer(header)
+ 
+ 	// keep a reference to the filename to allow to overwrite it later if we detect that we can use ustar longnames instead of pax
diff --git a/debian/patches/0003-archive-tar-reuse-temporary-buffer-in-readHeader.patch b/debian/patches/0003-archive-tar-reuse-temporary-buffer-in-readHeader.patch
new file mode 100644
index 0000000..01da107
--- /dev/null
+++ b/debian/patches/0003-archive-tar-reuse-temporary-buffer-in-readHeader.patch
@@ -0,0 +1,38 @@
+Description: archive/tar: reuse temporary buffer in readHeader
+Author: Cristian Staretu <unclejacksons at gmail.com>
+Last-Update: 2014-07-03
+Forwarded: not-needed
+Origin: vendor, https://code.google.com/p/go/source/detail?r=17404efd6b02d4b3acd17070e3f89de97a145877
+
+---
+
+diff -r 837348e418f3 -r 17404efd6b02 src/pkg/archive/tar/reader.go
+--- a/src/pkg/archive/tar/reader.go	Thu Jul 03 09:40:53 2014 +1000
++++ b/src/pkg/archive/tar/reader.go	Thu Jul 03 09:41:19 2014 +1000
+@@ -29,10 +29,11 @@
+ // The Next method advances to the next file in the archive (including the first),
+ // and then it can be treated as an io.Reader to access the file's data.
+ type Reader struct {
+-	r    io.Reader
+-	err  error
+-	pad  int64          // amount of padding (ignored) after current file entry
+-	curr numBytesReader // reader for current file entry
++	r       io.Reader
++	err     error
++	pad     int64           // amount of padding (ignored) after current file entry
++	curr    numBytesReader  // reader for current file entry
++	hdrBuff [blockSize]byte // buffer to use in readHeader
+ }
+ 
+ // A numBytesReader is an io.Reader with a numBytes method, returning the number
+@@ -426,7 +427,9 @@
+ }
+ 
+ func (tr *Reader) readHeader() *Header {
+-	header := make([]byte, blockSize)
++	header := tr.hdrBuff[:]
++	copy(header, zeroBlock)
++
+ 	if _, tr.err = io.ReadFull(tr.r, header); tr.err != nil {
+ 		return nil
+ 	}
diff --git a/debian/patches/series b/debian/patches/series
index 4117975..0267a2a 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,3 @@
 0001-backport-delete-whole-line.patch
+0002-archive-tar-reuse-temporary-buffer-in-writeHeader.patch
+0003-archive-tar-reuse-temporary-buffer-in-readHeader.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-golang/golang.git



More information about the pkg-golang-commits mailing list