[Pkg-libvirt-commits] [libguestfs] 236/384: builder: Fix large performance regression in pxzcat (RHBZ#1188866).

Hilko Bengen bengen at moszumanska.debian.org
Sun Mar 29 16:57:23 UTC 2015


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

bengen pushed a commit to branch experimental
in repository libguestfs.

commit ff1cf989fd49cfb82db428e66034c7b2d6bebe8a
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Wed Feb 4 13:17:40 2015 +0000

    builder: Fix large performance regression in pxzcat (RHBZ#1188866).
    
    Commit 9135129b0f6e8eb171131ea0f7d729a960b74cb3 changed
    two stack buffers to pointers:
    
    -  uint8_t buf[BUFFER_SIZE];
    -  unsigned char outbuf[BUFFER_SIZE];
    +  CLEANUP_FREE uint8_t *buf = NULL;
    +  CLEANUP_FREE uint8_t *outbuf = NULL;
    
    but we were still using sizeof buf to calculate the size of the
    buffer.  sizeof buf == 8 so the original code which used large buffers
    for reading/writing the file changed to using 8 byte buffers.
---
 builder/pxzcat-c.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builder/pxzcat-c.c b/builder/pxzcat-c.c
index bd4c0a8..0bbd296 100644
--- a/builder/pxzcat-c.c
+++ b/builder/pxzcat-c.c
@@ -640,14 +640,14 @@ worker_thread (void *vp)
     strm.next_in = NULL;
     strm.avail_in = 0;
     strm.next_out = outbuf;
-    strm.avail_out = sizeof outbuf;
+    strm.avail_out = BUFFER_SIZE;
 
     for (;;) {
       lzma_action action = LZMA_RUN;
 
       if (strm.avail_in == 0) {
         strm.next_in = buf;
-        n = pread (global->fd, buf, sizeof buf, position);
+        n = pread (global->fd, buf, BUFFER_SIZE, position);
         if (n == -1) {
           perror (global->filename);
           return &state->status;
@@ -661,7 +661,7 @@ worker_thread (void *vp)
       r = lzma_code (&strm, action);
 
       if (strm.avail_out == 0 || r == LZMA_STREAM_END) {
-        size_t wsz = sizeof outbuf - strm.avail_out;
+        size_t wsz = BUFFER_SIZE - strm.avail_out;
 
         /* Don't write if the block is all zero, to preserve output file
          * sparseness.  However we have to update oposition.
@@ -675,7 +675,7 @@ worker_thread (void *vp)
         oposition += wsz;
 
         strm.next_out = outbuf;
-        strm.avail_out = sizeof outbuf;
+        strm.avail_out = BUFFER_SIZE;
       }
 
       if (r == LZMA_STREAM_END)

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



More information about the Pkg-libvirt-commits mailing list