linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH RFC] 2.5.73 zlib #1 memmove
@ 2003-07-02  9:27 Etienne Lorrain
  0 siblings, 0 replies; 2+ messages in thread
From: Etienne Lorrain @ 2003-07-02  9:27 UTC (permalink / raw)
  To: linux-kernel

  Hi,

  I do not know if you are interrested, but I already did
 a lot work on zlib/gzlib in Gujin:
http://gujin.sourceforge.net/

 There is a near complete rewrite of zlib, even removing the
 32Kb window stuff. Unlike zlib, it is only licenced as GPL, and only
 tested on i386, in fact 32 bit processors. An unusual CRC32 function
 is also available, optimised to i386 instructions but without a table
 to reduce the data cache page misses and code size.

 Have a look at gzcopy.c:
gzcopy -t infile.gz    -> test the content of the file (-t0 for quite).

 The kind of testing done is in Makefile:
testgzlib: gzcopy
        find /mnt/cdrom/ -name "*.tgz" -o -name "*.gz" \
                -exec ./gzcopy -t {} \; 2>&1 | tee log

 I did it on multi CDROMs collection like ftp.cdrom.com , it checks
 all files CRC32 - the only failure were unreadable files on the device
 and file not compressed by GZIP (GZIP can decompress .Z and .ZIP files)
 even if someone changed their name to *.gz

 My aim there was code size reduction (4-5 Kbytes of code total).
 It does compile and work with GCC aliasing optimisation.

  Cheers,
  Etienne.

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

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

* [PATCH RFC] 2.5.73 zlib #1 memmove
@ 2003-07-01 15:45 Jörn Engel
  0 siblings, 0 replies; 2+ messages in thread
From: Jörn Engel @ 2003-07-01 15:45 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: linux-kernel

[ I currently have some mail problems that might take a while to
  resolve.  wohnheim.fh-wedel.de has a new dns-entry and the old one
  has a max lifetime on one week. :(

  I'm trying to resolve that problem but please keep linux-kernel on
  CC:. That way I can at least read the archives until the problems
  are history. ]

Joakim found a performance issue in the zlib and after some back and
forth, it appears that memmove() should be the correct solution.

The code in question copies a string from the LZ77 sliding window into
the output buffer.  The string is 3-258 bytes long with a tendency
towards small strings.  The zlib uses this code to do the copy:

*q++ = *r++;  c--;
*q++ = *r++;  c--;
do {
	*q++ = *r++;
} while (--c);

The first two lines are loop unrolling.  Apart from being ugly, this
should also be slower than memmove(), so I propose this patch.

Jörn

-- 
Fantasy is more important than knowlegde. Knowlegde is limited,
while fantasy embraces the whole world.
-- Albert Einstein

--- linux-2.5.73/lib/zlib_inflate/inffast.c~zlib_memcpy	2003-06-30 03:51:54.000000000 +0200
+++ linux-2.5.73/lib/zlib_inflate/inffast.c	2003-06-30 04:22:32.000000000 +0200
@@ -20,6 +20,14 @@
 #define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}}
 #define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;}
 
+static inline void memmove_update(Byte **dest, Byte **src, size_t *n)
+{
+	memmove(*dest, *src, *n);
+	*dest += *n;
+	*src += *n;
+	*n = 0;
+}
+
 /* Called with number of bytes left to write in window at least 258
    (the maximum string length) and number of input bytes available
    at least ten.  The ten bytes are six bytes for the longest length/
@@ -100,30 +108,18 @@
               if (c > e)
               {
                 c -= e;                         /* wrapped copy */
-                do {
-                    *q++ = *r++;
-                } while (--e);
+		memmove_update(&q, &r, &e);
                 r = s->window;
-                do {
-                    *q++ = *r++;
-                } while (--c);
+		memmove_update(&q, &r, &c);
               }
               else                              /* normal copy */
               {
-                *q++ = *r++;  c--;
-                *q++ = *r++;  c--;
-                do {
-                    *q++ = *r++;
-                } while (--c);
+		memmove_update(&q, &r, &c);
               }
             }
             else                                /* normal copy */
             {
-              *q++ = *r++;  c--;
-              *q++ = *r++;  c--;
-              do {
-                *q++ = *r++;
-              } while (--c);
+              memmove_update(&q, &r, &c);
             }
             break;
           }

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

end of thread, other threads:[~2003-07-02  9:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-02  9:27 [PATCH RFC] 2.5.73 zlib #1 memmove Etienne Lorrain
  -- strict thread matches above, loose matches on Subject: below --
2003-07-01 15:45 Jörn Engel

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