Hottest Free Downloads - DownloadPipe.com Over 197,000 downloads! Bookmark Now!
DownloadPipe.com - New Downloads Every Minute
 SEARCH:
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

[PATCH] zlib: Optimize inffast even more

 
   Linux (Home) -> Kernel RSS
Next:  Bug#550625: libc6 2.7-18 realloc bug is NOT fixed  
Author Message
Joakim Tjernlund

External


Since: Nov 09, 2009
Posts: 1



(Msg. 1) Posted: Mon Nov 09, 2009 6:25 am
Post subject: [PATCH] zlib: Optimize inffast even more
Archived from groups: linux>kernel (more info?)

This improves zlib: Optimize inffast when copying direct from output
and gives another 3-4% improvement for my MPC8321 target.
Does not need CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
uses get_unaligned() but only in one place.
The copy loop just above this one can also use this
optimization, but I havn't done so as I have not tested if it
is a win there too.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund.TakeThisOut@transmode.se>
---

Someone with a little endian target should test too.

arch/powerpc/boot/Makefile | 1 +
lib/zlib_inflate/inffast.c | 54 ++++++++++++++++++++++----------------------
2 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 9ae7b7e..33335be 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -34,6 +34,7 @@ BOOTCFLAGS += -fno-stack-protector
endif

BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj)
+BOOTCFLAGS += -Iarch/powerpc/include

DTS_FLAGS ?= -p 1024

diff --git a/lib/zlib_inflate/inffast.c b/lib/zlib_inflate/inffast.c
index 0588fbf..4f78567 100644
--- a/lib/zlib_inflate/inffast.c
+++ b/lib/zlib_inflate/inffast.c
@@ -4,6 +4,7 @@
*/

#include <linux/zutil.h>
+#include <asm/unaligned.h>
#include "inftrees.h"
#include "inflate.h"
#include "inffast.h"
@@ -24,9 +25,11 @@
#ifdef POSTINC
# define OFF 0
# define PUP(a) *(a)++
+# define UP_UNALIGNED(a) get_unaligned((a)++)
#else
# define OFF 1
# define PUP(a) *++(a)
+# define UP_UNALIGNED(a) get_unaligned(++(a))
#endif

/*
@@ -240,52 +243,49 @@ void inflate_fast(z_streamp strm, unsigned start)
}
else {
from = out - dist; /* copy direct from output */
-#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
/* minimum length is three */
if (dist > 2 ) {
- unsigned short *sout = (unsigned short *)(out - OFF);
- unsigned short *sfrom = (unsigned short *)(from - OFF);
- unsigned long loops = len >> 1;
+ unsigned short *sout;
+ unsigned short *sfrom;
+ unsigned long loops;

+ /* Align out addr, only sfrom might be unaligned */
+ if (!((long)(out - 1 + OFF)) & 1) {
+ PUP(out) = PUP(from);
+ len--;
+ }
+ sout = (unsigned short *)(out - OFF);
+ sfrom = (unsigned short *)(from - OFF);
+ loops = len >> 1;
do
- PUP(sout) = PUP(sfrom);
+ PUP(sout) = UP_UNALIGNED(sfrom);
while (--loops);
out = (unsigned char *)sout + OFF;
from = (unsigned char *)sfrom + OFF;
if (len & 1)
PUP(out) = PUP(from);
- } else if (dist == 2) {
- unsigned short *sout = (unsigned short *)(out - OFF);
+ } else { /* dist == 1 or dist == 2 */
+ unsigned short *sout;
unsigned short pat16;
- unsigned long loops = len >> 1;
+ unsigned long loops;

+ /* Align out addr */
+ if (!((long)(out - 1 + OFF)) & 1) {
+ PUP(out) = PUP(from);
+ len--;
+ }
+ sout = (unsigned short *)(out - OFF);
pat16 = *(sout-2+2*OFF);
+ if (dist == 1)
+ pat16 = (pat16 & 0xff) | ((pat16 & 0xff ) << Cool;
+ loops = len >> 1;
do
PUP(sout) = pat16;
while (--loops);
out = (unsigned char *)sout + OFF;
if (len & 1)
PUP(out) = PUP(from);
- } else {
- unsigned char pat8 = *(out - 1 + OFF);
-
- do {
- PUP(out) = pat8;
- } while (--len);
}
-#else
- do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- } while (len > 2);
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
-#endif
}
}
else if ((op & 64) == 0) { /* 2nd level distance code */
--
1.6.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.TakeThisOut@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Andrew Morton

External


Since: Jul 15, 2009
Posts: 42



(Msg. 2) Posted: Wed Nov 11, 2009 7:26 pm
Post subject: Re: [PATCH] zlib: Optimize inffast even more [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Mon, 9 Nov 2009 11:22:16 +0100
Joakim Tjernlund <Joakim.Tjernlund RemoveThis @transmode.se> wrote:

> This improves zlib: Optimize inffast when copying direct from output
> and gives another 3-4% improvement for my MPC8321 target.
> Does not need CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
> uses get_unaligned() but only in one place.
> The copy loop just above this one can also use this
> optimization, but I havn't done so as I have not tested if it
> is a win there too.
>
> Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund RemoveThis @transmode.se>
> ---
>
> Someone with a little endian target should test too.

eh? That requires a PC. Can't you test it??
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo RemoveThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Joakim Tjernlund

External


Since: Nov 12, 2009
Posts: 2



(Msg. 3) Posted: Thu Nov 12, 2009 3:25 am
Post subject: Re: [PATCH] zlib: Optimize inffast even more [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

roel kluin <roel.kluin.RemoveThis@gmail.com> wrote on 12/11/2009 00:46:41:
>
> On Mon, Nov 9, 2009 at 11:22 AM, Joakim Tjernlund
> <Joakim.Tjernlund.RemoveThis@transmode.se> wrote:
> > This improves zlib: Optimize inffast when copying direct from output
> > and gives another 3-4% improvement for my MPC8321 target.
> > Does not need CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
> > uses get_unaligned() but only in one place.
> > The copy loop just above this one can also use this
> > optimization, but I havn't done so as I have not tested if it
> > is a win there too.
> >
> > Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund.RemoveThis@transmode.se>
> > ---
>
>
> > @@ -240,52 +243,49 @@ void inflate_fast(z_streamp strm, unsigned start)
> >                 }
> >                 else {
> >                     from = out - dist;          /* copy direct from output */
> > -#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
> >                     /* minimum length is three */
> >                    if (dist > 2 ) {
> > -                       unsigned short *sout = (unsigned short *)(out - OFF);
> > -                       unsigned short *sfrom = (unsigned short *)(from - OFF);
> > -                       unsigned long loops = len >> 1;
> > +                       unsigned short *sout;
> > +                       unsigned short *sfrom;
> > +                       unsigned long loops;
> >
> > +                       /* Align out addr, only sfrom might be unaligned */
> > +                       if (!((long)(out - 1 + OFF)) & 1) {
>
> I think this is wrong
>
> did you mean
>
> if (!((long)(out - 1 + OFF) & 1))

Yes, will fix and send out a new patch with
cleanups and fixes for CPUs that cannot do unaligned
accesses. Thanks

Jocke

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Joakim Tjernlund

External


Since: Nov 12, 2009
Posts: 2



(Msg. 4) Posted: Thu Nov 12, 2009 6:25 am
Post subject: Re: [PATCH] zlib: Optimize inffast even more [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Andrew Morton <akpm.DeleteThis@linux-foundation.org> wrote on 12/11/2009 00:24:45:
>
> On Mon, 9 Nov 2009 11:22:16 +0100
> Joakim Tjernlund <Joakim.Tjernlund.DeleteThis@transmode.se> wrote:
>
> > This improves zlib: Optimize inffast when copying direct from output
> > and gives another 3-4% improvement for my MPC8321 target.
> > Does not need CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
> > uses get_unaligned() but only in one place.
> > The copy loop just above this one can also use this
> > optimization, but I havn't done so as I have not tested if it
> > is a win there too.
> >
> > Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund.DeleteThis@transmode.se>
> > ---
> >
> > Someone with a little endian target should test too.
>
> eh? That requires a PC. Can't you test it??

It needs something that actually uses the inflate too on that PC and
I don't have that handy.
Anyhow, I downloaded zip and made the changes and tested a little, found
a problem. Will resend a new patch with everything in it soon.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.DeleteThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Display posts from previous:   
Related Topics:
[patch] bh_lru_install() optimize - Hello, This optimizes bh_lru_install(). It's a hot spot I think. The bh_lru is well manipulated now so we can use put_bh() as a substitute for the first __brelse() here, and a bogus BUG_ON() can be removed safely. We evict at the right place too. Boo...

[PATCH] cpuset semaphore depth check optimize - Optimize the deadlock avoidance check on the global cpuset semaphore cpuset_sem. Instead of adding a depth counter to the task struct of each task, rather just two words are enough, one to store the depth and the other the current cpuset_sem holder. ..

[PATCH 12/13] hrtimer: optimize hrtimer_get_remaining - hrtimer_get_remaining doesn't need to lock the hrtimer_base to read the time. Also use hrtimer_get_remaining at two other places. Signed-off-by: Roman Zippel <zippel@linux-m68k.org> kernel/hrtimer.c | 18 +++--------------- 1 file changed, 3..

[PATCH mmotm] vfs: optimize touch_time too fix - Recent mmotms give me WARNING: at fs/namespace.c:612 mntput_no_expire()+... when unmounting: __mntput()'s WARN_ON(count_mnt_writers(mnt)). That's because vfs-optimize-touch_time-too.patch inverted the sense of mnt_want_write_file(), which is..

[2.6 patch] lib/zlib*: possible cleanups - This patch contains the following possible cleanups: - #if 0 the following unused functions: - zlib_deflate/deflate.c: zlib_deflateSetDictionary - zlib_deflate/deflate.c: zlib_deflateParams - zlib_deflate/deflate.c: zlib_deflateCopy -..
       Linux (Home) -> Kernel All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Categories:
 Windows Forums
 Game Forums
  Linux Forums
 Mac Forums
 PDA Forums
 Mobile Forums
  Top  |  Store  |  RSS Feeds RSS  |  Data Feeds  |  Advertise  |  Submit  |  Bookmark  |  Newsletter  |  Contact