On Tue, 2003-05-27 at 20:42, Joakim Tjernlund wrote:> Hi Samba
>
> I noticed that the crc32 function in lib/crc32.c is somewhat
> inefficient. This little patch will reduce the inner loop from 10
> instructions to 8 instructions on x86 with gcc. gcc can't figure
> out this simple optimization by itself on x86.
So, we are saving two instructions... I think this e-mail consumed more
;-)
> Further optimization is possible by using the impl. in the linux 2.5
kernel, but
> I don't know if it is worth it. Is crc32 common in samba? What would
the typical
> buffer len be?
It's reasonably rare. It's certainly not in any fast-paths that I know
of.
> Jocke
>
> Patch against 2_2_8 CVS:
> --- lib/crc32.c Sat Oct 20 23:23:35 2001
> +++ lib/crc32.c.new Tue May 13 14:45:31 2003
> @@ -60,7 +60,7 @@
> uint32 crc=0xffffffff;
> int i;
> for(i=0;i<count;i++)
> - crc = (crc>>8) ^ CRCTable[(buffer[i] ^ crc) &
0xff];
> + crc = CRCTable[(buffer[i] ^ crc) & 0xff] ^
(crc>>8);
> crc^=0xffffffff;
> DEBUG(10,("crc32_calc_buffer: %x\n", crc));
> dump_data(100, buffer, count);
Looks reasonable, but I'll let somebody else chase it up.
Andrew Bartlett
--
Andrew Bartlett abartlet@pcug.org.au
Manager, Authentication Subsystems, Samba Team abartlet@samba.org
Student Network Administrator, Hawker College abartlet@hawkerc.net
http://samba.org http://build.samba.org http://hawkerc.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url :
http://lists.samba.org/archive/samba/attachments/20030527/376560ac/attachment.bin