From: hugang <hugang@soulinfo.com>
To: Thomas Schlichter <schlicht@uni-mannheim.de>
Cc: willy@w.ods.org, linux-kernel@vger.kernel.org, akpm@digeo.com
Subject: Re: [RFC][PATCH] Faster generic_fls
Date: Fri, 2 May 2003 08:33:01 +0800 [thread overview]
Message-ID: <20030502083301.58827934.hugang@soulinfo.com> (raw)
In-Reply-To: <200305011754.33233.schlicht@uni-mannheim.de>
On Thu, 1 May 2003 17:54:28 +0200
Thomas Schlichter <schlicht@uni-mannheim.de> wrote:
> Hi,
>
> On March 1, hugang wrote:
> > On Thu, 1 May 2003 15:52:04 +0200
> >
> > Willy TARREAU <willy@w.ods.org> wrote:
> > > However, I have good news for you, the table code is 15% faster than my
> > > tree on an Alpha EV6 ;-)
> > > It may be because gcc can use different tricks on this arch.
> > >
> > > Cheers
> > > Willy
> >
> > However, The most code changed has increase a little peformance, Do we
> > really need it?
> >
> > Here is test in my machine, The faster is still table.
>
> I think the table version is so fast as a normal distribution of numbers is
> tested. With this distribution half of the occuring values have the MSB set,
> one quarter the next significant bit and so on...
>
> The tree version is approximately equally fast for every number, but the table
> version is fast if a very significant bit is set and slow if a less
> significant bit is set...
>
> If small values occour more often than big ones the tree version should be
> preferred, else following version may be very fast, too.
>
> static inline int fls_shift(int x)
> {
> int bit = 32;
>
> while(x > 0) {
> --bit;
> x <<= 1;
> }
>
> return x ? bit : 0;
> }
>
Yes, The shift is very faster than other. Here is a test in P4 1.6G.
model name : Intel(R) Pentium(R) 4 Mobile CPU 1.60GHz
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
==== -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686 ====
test_fls.c: In function `fls_tree_fls':
test_fls.c:85: warning: type defaults to `int' in declaration of `t'
4294967295 iterations of nil... checksum = 4294967295
real 0m21.698s
user 0m21.650s
sys 0m0.000s
4294967295 iterations of table... checksum = 4294967265
real 0m41.581s
user 0m41.500s
sys 0m0.000s
4294967295 iterations of tree... checksum = 4294967265
real 1m1.173s
user 1m1.040s
sys 0m0.000s
4294967295 iterations of shift... checksum = 4294967265
real 0m22.050s
user 0m22.000s
sys 0m0.010s
--
Hu Gang / Steve
Email : huagng@soulinfo.com, steve@soulinfo.com
GPG FinePrint: 4099 3F1D AE01 1817 68F7 D499 A6C2 C418 86C8 610E
ICQ# : 205800361
Registered Linux User : 204016
next prev parent reply other threads:[~2003-05-02 0:21 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-30 2:46 Daniel Phillips
2003-04-30 7:19 ` Willy Tarreau
2003-04-30 8:36 ` Aaron Lehmann
2003-04-30 8:43 ` Aaron Lehmann
2003-04-30 8:52 ` Aaron Lehmann
2003-04-30 8:51 ` P
2003-04-30 13:51 ` Daniel Phillips
2003-04-30 11:14 ` Falk Hueffner
2003-04-30 13:03 ` Daniel Phillips
2003-04-30 13:17 ` Falk Hueffner
2003-04-30 14:07 ` Daniel Phillips
2003-04-30 14:11 ` Linus Torvalds
2003-04-30 14:53 ` Falk Hueffner
2003-04-30 15:28 ` Linus Torvalds
2003-04-30 16:03 ` Falk Hueffner
2003-04-30 16:16 ` Linus Torvalds
2003-04-30 16:43 ` Falk Hueffner
2003-04-30 20:25 ` Alan Cox
2003-04-30 21:59 ` Falk Hueffner
2003-04-30 22:22 ` Alan Cox
2003-04-30 23:41 ` Linus Torvalds
2003-04-30 22:47 ` Alan Cox
2003-05-01 0:12 ` Falk Hueffner
2003-05-01 1:07 ` Linus Torvalds
2003-04-30 19:15 ` Daniel Phillips
2003-04-30 20:59 ` Willy Tarreau
2003-05-01 1:02 ` Daniel Phillips
2003-05-01 9:19 ` Willy Tarreau
2003-05-01 16:02 ` Linus Torvalds
2003-04-30 20:55 ` Andrew Morton
2003-05-01 5:03 ` hugang
2003-05-01 5:11 ` Andrew Morton
2003-05-01 5:33 ` hugang
2003-05-01 7:05 ` hugang
2003-05-01 13:52 ` Willy TARREAU
2003-05-01 14:14 ` Falk Hueffner
2003-05-01 14:26 ` Willy TARREAU
2003-05-01 14:53 ` hugang
2003-05-01 15:54 ` Thomas Schlichter
2003-05-02 0:33 ` hugang [this message]
2003-05-01 17:16 ` Willy TARREAU
2003-05-01 23:27 ` Thomas Schlichter
2003-05-02 0:10 ` Willy Tarreau
2003-05-02 0:43 ` Daniel Phillips
2003-05-02 0:54 ` Andrew Morton
2003-05-02 12:21 ` Daniel Phillips
2003-05-02 1:47 ` Thomas Schlichter
2003-05-02 13:24 ` Willy Tarreau
2003-05-02 0:13 ` Daniel Phillips
2003-05-02 0:13 ` Lincoln Dale
2003-05-01 5:16 ` hugang
2003-05-01 10:22 ` Willy TARREAU
2003-05-01 11:17 ` hugang
2003-05-01 11:45 ` Willy TARREAU
[not found] <87d6j34jad.fsf@student.uni-tuebingen.de.suse.lists.linux.kernel>
[not found] ` <Pine.LNX.4.44.0304301801210.20283-100000@home.transmeta.com.suse.lists.linux.kernel>
2003-05-01 1:46 ` Andi Kleen
2003-05-01 4:40 ` Linus Torvalds
2003-05-01 12:00 ` David S. Miller
2003-05-02 5:14 ` Linus Torvalds
2003-05-01 13:31 linux
2003-05-01 17:15 Chuck Ebbert
2003-05-02 8:50 Chuck Ebbert
2003-05-02 9:37 ` Peter Osterlund
2003-05-02 10:04 Chuck Ebbert
2003-05-02 22:55 ` David S. Miller
2003-05-03 2:21 Chuck Ebbert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030502083301.58827934.hugang@soulinfo.com \
--to=hugang@soulinfo.com \
--cc=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=schlicht@uni-mannheim.de \
--cc=willy@w.ods.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®