From: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
To: "Artem B. Bityuckiy" <dedekind@infradead.org>
Cc: Linux MTD mailing list <linux-mtd@lists.infradead.org>,
Thomas Gleixner <tglx@linutronix.de>,
Joakim Tjernlund <joakim.tjernlund@lumentis.se>
Subject: Re: JFFS3 & performance
Date: Wed, 22 Dec 2004 16:14:03 +0100 [thread overview]
Message-ID: <20041222151403.GA8943@wohnheim.fh-wedel.de> (raw)
In-Reply-To: <Pine.LNX.4.58.0412221442510.30556@phoenix.infradead.org>
On Wed, 22 December 2004 14:44:35 +0000, Artem B. Bityuckiy wrote:
>
> > How about adding adler32 and possibly this algorithm? Engel32
> > (missing a better name) is basically adler32, but instead of a
> > modula-operation, it mirrors one of the two checksums (last bit
> > becomes first, etc.) and XORs both.
> Adler32 was added. Engel32 too.
>
> Did yiu investigate theoretically these algorithms? Why engel32 is weaker?
Yup, engel32 should be roughly the same. Here are the details:
o Both algorithms calculate two checksum. One is the sum of all input
characters, the other is the sum of (input character x position),
where the position is counted backwards.
From here on, they are called "sum" and "product".
o Either sum or product is a weak checksum.
o The combination of sum and product is a strong checksum.
Differences show up in how sum and product are combined:
o Adler32 splits the 32bit checksum in 16 bits for sum and 16 bits for
product. Both are calculated seperately in 32bit variables. In the
end, a modulo 65521 operation folds the higher bits of each checksum
to the lower 16 bits and both parts are concatenated.
o Engel32 mirrors the sum and xors sum and product.
Problems of adler32:
o The product checksum grows faster than the sum checksum. For some
input data, the product holds more than 16 bits of relevant
information, while the sum holds less. After combining both, only
16 bits of the product are used, so the result has less than 32 bits
of relevant information.
Problems of engel32:
o When creating sum and product, high bits can never influence low
bits, while low bits influence high bits. Using modulo in adler32
causes high bits to influence low bits as well. For engel32, the
high bits of product never influence low bit again.
In the end, I guess that neither of the two problems matter and
adler32 has the advantage of being well-known and proven.
> Would somebody like to add backward CRCs to the test?
Here is backward engel32. It runs about 1.5% faster than forward
engel32 in my hash test. Other backward algorithms should be in the
same order (depending on hardware).
uint32_t engel32r(uint32_t engel, const void *_s, size_t len)
{
const char *s = _s;
uint32_t sum=engel, prod=engel;
for (; len>=4; len-=4, s+=4) {
sum += s[len-1];
prod += sum;
sum += s[len-2];
prod += sum;
sum += s[len-3];
prod += sum;
sum += s[len-4];
prod += sum;
}
for (; len; len--, s++) {
sum += s[len];
prod += sum;
}
sum = (sum&0x0000ffff)<<16^ (sum&0xffff0000)>>16;
sum = (sum&0x00ff00ff)<<8 ^ (sum&0xff00ff00)>>8;
sum = (sum&0x0f0f0f0f)<<4 ^ (sum&0xf0f0f0f0)>>4;
sum = (sum&0x33333333)<<2 ^ (sum&0xcccccccc)>>2;
sum = (sum&0x55555555)<<1 ^ (sum&0xaaaaaaaa)>>1;
prod ^= sum;
return prod;
}
> I ran test on i686 (just to see it is compiled and works). Results are:
>
> [crctst] 16-bit CRC CCITT 32 bytes: ts1 14352216056936, ts2
> 14352216057276, delta 340
> [crctst] 16-bit CRC CCITT 4096 bytes: ts1 14352237257556, ts2
> 14352237286332, delta 28776
> [crctst] 16-bit CRC CCITT 65536 bytes: ts1 14352259870036, ts2
> 14352260333528, delta 463492
> [crctst] crc32 32 bytes: ts1 14352282934664, ts2 14352282934980, delta 316
> [crctst] crc32 4096 bytes: ts1 14352301401184, ts2 14352301429996, delta
> 28812
> [crctst] crc32 65536 bytes: ts1 14352321296456, ts2 14352321726112, delta
> 429656
> [crctst] crc32c 32 bytes: ts1 14352341677716, ts2 14352341678048, delta
> 332
> [crctst] crc32c 4096 bytes: ts1 14352360411764, ts2 14352360436508, delta
> 24744
> [crctst] crc32c 65536 bytes: ts1 14352380586256, ts2 14352381043780, delta
> 457524
> [crctst] adler32 32 bytes: ts1 14352401248340, ts2 14352401248540, delta
> 200
> [crctst] adler32 4096 bytes: ts1 14352420251940, ts2 14352420256744, delta
> 4804
> [crctst] adler32 65536 bytes: ts1 14352439968500, ts2 14352440043460,
> delta 74960
> [crctst] engel32 32 bytes: ts1 14352460224760, ts2 14352460224960, delta
> 200
> [crctst] engel32 4096 bytes: ts1 14352479232376, ts2 14352479240700, delta
> 8324
> [crctst] engel32 65536 bytes: ts1 14352499089344, ts2 14352499228820,
> delta 139476
Adler32 beats the hell out of every other algorithm. Except for the
backwards part, it appears to be a clear winner.
Jörn
--
Rules of Optimization:
Rule 1: Don't do it.
Rule 2 (for experts only): Don't do it yet.
-- M.A. Jackson
next prev parent reply other threads:[~2004-12-22 15:14 UTC|newest]
Thread overview: 196+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-16 13:20 JFFS3 & performance Joakim Tjernlund
2004-12-16 14:27 ` Artem B. Bityuckiy
2004-12-16 14:45 ` Joakim Tjernlund
2004-12-16 14:50 ` Artem B. Bityuckiy
2004-12-16 15:00 ` Joakim Tjernlund
2004-12-16 17:53 ` Jörn Engel
2004-12-16 18:42 ` Artem B. Bityuckiy
2004-12-16 19:15 ` Jörn Engel
2004-12-16 19:49 ` Jörn Engel
2004-12-16 19:58 ` Joakim Tjernlund
2004-12-16 20:46 ` Jörn Engel
2004-12-16 20:02 ` Joakim Tjernlund
2004-12-16 20:37 ` Thomas Gleixner
2004-12-16 20:51 ` Jörn Engel
2004-12-16 21:02 ` Thomas Gleixner
2004-12-16 21:06 ` Joakim Tjernlund
2004-12-16 21:22 ` Jörn Engel
2004-12-16 22:06 ` Joakim Tjernlund
2004-12-17 10:25 ` Jörn Engel
2004-12-17 10:44 ` Joakim Tjernlund
2004-12-17 10:56 ` Artem B. Bityuckiy
2004-12-17 10:46 ` jasmine
2004-12-17 11:01 ` Artem B. Bityuckiy
2004-12-17 11:19 ` Joakim Tjernlund
2004-12-18 16:09 ` Jörn Engel
2004-12-18 16:26 ` Joakim Tjernlund
2004-12-18 16:52 ` Jörn Engel
2004-12-17 11:10 ` Joakim Tjernlund
2004-12-17 11:20 ` Artem B. Bityuckiy
2004-12-22 13:36 ` Artem B. Bityuckiy
2004-12-22 14:03 ` Jörn Engel
2004-12-22 14:44 ` Artem B. Bityuckiy
2004-12-22 15:14 ` Jörn Engel [this message]
2004-12-22 15:25 ` Artem B. Bityuckiy
2004-12-22 16:08 ` Jörn Engel
2004-12-22 20:22 ` xemc
2004-12-22 20:43 ` xemc
2004-12-22 20:49 ` Jasmine Strong
2004-12-22 15:30 ` Joakim Tjernlund
2004-12-22 15:37 ` Artem B. Bityuckiy
2004-12-22 15:47 ` Joakim Tjernlund
2004-12-22 15:56 ` Artem B. Bityuckiy
2004-12-22 16:09 ` Jörn Engel
2004-12-22 16:17 ` Artem B. Bityuckiy
2004-12-22 16:43 ` Joakim Tjernlund
2004-12-22 16:46 ` Artem B. Bityuckiy
2004-12-22 17:26 ` Jörn Engel
2004-12-22 18:14 ` xemc
2004-12-22 18:20 ` Artem B. Bityuckiy
2004-12-23 13:52 ` Jörn Engel
2004-12-23 17:02 ` Artem B. Bityuckiy
2005-01-07 11:10 ` Artem B. Bityuckiy
2005-01-07 11:09 ` David Woodhouse
2005-01-07 11:27 ` jasmine
2005-01-07 11:43 ` Artem B. Bityuckiy
2005-01-07 14:23 ` Artem B. Bityuckiy
2005-01-07 14:27 ` jasmine
2005-01-07 14:33 ` Artem B. Bityuckiy
2005-01-07 14:37 ` jasmine
2005-01-07 14:43 ` Artem B. Bityuckiy
2005-01-07 14:55 ` jasmine
2005-01-07 15:20 ` Artem B. Bityuckiy
2005-01-07 15:24 ` jasmine
2005-01-07 15:28 ` Artem B. Bityuckiy
2005-01-07 15:31 ` jasmine
2005-01-07 15:32 ` Artem B. Bityuckiy
2005-01-07 17:57 ` Artem B. Bityuckiy
2005-01-07 14:50 ` Artem B. Bityuckiy
2005-01-07 14:31 ` Artem B. Bityuckiy
2005-01-06 10:08 ` Artem B. Bityuckiy
2005-01-08 20:14 ` Jörn Engel
2005-01-09 11:39 ` Artem B. Bityuckiy
2005-01-10 14:24 ` Jörn Engel
2004-12-22 15:59 ` jasmine
2004-12-22 16:19 ` Jörn Engel
2004-12-22 16:21 ` Artem B. Bityuckiy
2004-12-22 15:56 ` Jörn Engel
2004-12-22 16:39 ` Joakim Tjernlund
2004-12-22 17:33 ` Jörn Engel
2004-12-17 11:20 ` Jörn Engel
2004-12-18 12:23 ` Artem B. Bityuckiy
2004-12-21 14:45 ` Artem B. Bityuckiy
2004-12-21 16:03 ` Jörn Engel
2004-12-17 11:33 ` David Vrabel
2004-12-17 15:34 ` Joakim Tjernlund
2004-12-18 16:14 ` Jörn Engel
2004-12-18 16:25 ` Joakim Tjernlund
2004-12-18 16:39 ` Jörn Engel
2004-12-18 17:10 ` Joakim Tjernlund
2004-12-18 17:19 ` Jörn Engel
2004-12-18 17:51 ` Joakim Tjernlund
2004-12-18 17:59 ` Jörn Engel
2004-12-18 18:13 ` Joakim Tjernlund
2004-12-19 3:05 ` Jörn Engel
2004-12-18 18:09 ` Joakim Tjernlund
2004-12-21 14:38 ` Jörn Engel
-- strict thread matches above, loose matches on Subject: below --
2005-01-11 12:29 Artem B. Bityuckiy
2005-01-11 14:37 ` Josh Boyer
2005-01-11 21:51 ` Jörn Engel
2005-01-12 0:06 ` Thomas Gleixner
2005-01-12 16:59 ` Jörn Engel
2005-01-12 17:37 ` Thomas Gleixner
2005-01-12 18:17 ` Jörn Engel
2005-01-12 9:15 ` Artem B. Bityuckiy
2005-01-12 16:41 ` Jared Hulbert
2005-01-12 17:02 ` Jörn Engel
2005-01-12 17:06 ` David Woodhouse
2005-01-12 17:11 ` Jörn Engel
2005-01-12 17:22 ` Jared Hulbert
2005-01-12 17:28 ` Artem B. Bityuckiy
2005-01-12 17:34 ` David Woodhouse
2005-01-12 17:45 ` Dan Post
2005-01-12 17:52 ` David Woodhouse
2005-01-12 17:14 ` Artem B. Bityuckiy
2005-01-12 22:30 ` Jared Hulbert
2005-01-12 22:43 ` Josh Boyer
2005-01-12 22:55 ` Jared Hulbert
2005-01-13 15:50 ` Josh Boyer
2005-01-13 18:30 ` Jared Hulbert
2005-01-13 18:36 ` David Woodhouse
2005-01-13 19:06 ` Jörn Engel
2005-01-13 19:22 ` Josh Boyer
2005-01-13 18:55 ` Artem B. Bityuckiy
2005-01-13 19:10 ` Brian Fox
2005-01-13 19:23 ` Artem B. Bityuckiy
2005-01-28 6:08 ` Eric W. Biederman
2005-01-13 7:54 ` David Woodhouse
2005-01-13 8:25 ` Artem B. Bityuckiy
2005-01-13 15:09 ` Jörn Engel
2005-01-12 18:10 ` Jörn Engel
2005-01-12 18:27 ` Thomas Gleixner
2005-01-12 18:40 ` Jörn Engel
2005-01-12 18:42 ` David Woodhouse
2005-01-12 18:43 ` Artem B. Bityuckiy
2005-01-12 19:16 ` Thomas Gleixner
2005-01-12 19:44 ` Jörn Engel
2005-01-12 19:53 ` Thomas Gleixner
2005-01-12 20:06 ` Jörn Engel
2005-01-12 18:33 ` Artem B. Bityuckiy
2005-01-12 18:43 ` Jörn Engel
2005-01-12 18:45 ` Artem B. Bityuckiy
2005-01-12 18:58 ` Artem B. Bityuckiy
2005-01-12 19:50 ` Jörn Engel
2005-01-13 14:49 ` Artem B. Bityuckiy
2005-01-13 15:05 ` Artem B. Bityuckiy
2005-01-13 15:17 ` Jörn Engel
2005-01-13 15:22 ` Artem B. Bityuckiy
2005-01-13 15:40 ` Jörn Engel
2005-01-13 15:49 ` David Woodhouse
2005-01-13 15:53 ` Artem B. Bityuckiy
2005-01-13 16:13 ` Jörn Engel
2005-01-13 16:16 ` Artem B. Bityuckiy
2005-01-13 16:21 ` Jörn Engel
2005-01-13 16:22 ` Artem B. Bityuckiy
2005-01-13 16:21 ` Artem B. Bityuckiy
2005-01-14 13:46 ` Jamey Hicks
2005-01-14 14:16 ` Artem B. Bityuckiy
2005-01-18 15:50 ` Joakim Tjernlund
2005-01-19 13:07 ` Artem B. Bityuckiy
2005-01-19 15:24 ` Jörn Engel
2005-01-19 15:27 ` Artem B. Bityuckiy
2005-01-19 15:32 ` Jörn Engel
2005-01-19 15:51 ` Artem B. Bityuckiy
2005-01-19 16:31 ` Jörn Engel
2005-01-19 19:58 ` Artem B. Bityuckiy
2005-01-20 14:35 ` Jörn Engel
2005-01-20 14:37 ` David Woodhouse
2005-01-20 14:40 ` Jörn Engel
2005-01-20 15:05 ` Artem B. Bityuckiy
2005-01-20 15:27 ` Jörn Engel
2005-01-20 15:37 ` Artem B. Bityuckiy
2005-01-20 16:13 ` Jörn Engel
2005-01-20 16:31 ` Artem B. Bityuckiy
2005-01-20 16:41 ` Jörn Engel
2005-01-20 17:08 ` Artem B. Bityuckiy
2005-01-20 17:33 ` Jörn Engel
2005-01-20 17:57 ` Artem B. Bityuckiy
2005-01-21 12:44 ` Jörn Engel
2005-01-21 13:13 ` Artem B. Bityuckiy
2005-01-21 13:42 ` Jörn Engel
2005-01-21 13:52 ` Artem B. Bityuckiy
2005-01-21 14:00 ` Jörn Engel
2005-01-21 14:04 ` Artem B. Bityuckiy
2005-01-25 10:51 ` Jörn Engel
2005-01-25 10:56 ` David Woodhouse
2005-01-25 11:13 ` Jörn Engel
2005-01-21 14:30 ` Josh Boyer
2005-01-21 22:33 ` Jared Hulbert
2005-01-21 22:46 ` Jared Hulbert
2005-01-21 23:54 ` Josh Boyer
2005-01-22 13:03 ` Artem B. Bityuckiy
2005-01-22 22:04 ` David Woodhouse
2005-01-23 10:03 ` Artem B. Bityuckiy
2005-01-23 10:08 ` Artem B. Bityuckiy
2005-01-23 11:04 ` David Woodhouse
2005-01-23 11:55 ` Artem B. Bityuckiy
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=20041222151403.GA8943@wohnheim.fh-wedel.de \
--to=joern@wohnheim.fh-wedel.de \
--cc=dedekind@infradead.org \
--cc=joakim.tjernlund@lumentis.se \
--cc=linux-mtd@lists.infradead.org \
--cc=tglx@linutronix.de \
/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