Re: Cost of XLogInsert CRC calculations

From: "Mark Cave-Ayland" <m(dot)cave-ayland(at)webbased(dot)co(dot)uk>
To: "'Simon Riggs'" <simon(at)2ndquadrant(dot)com>
Cc: "'Christopher Kings-Lynne'" <chriskl(at)familyhealth(dot)com(dot)au>, "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "'Bruce Momjian'" <pgman(at)candle(dot)pha(dot)pa(dot)us>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cost of XLogInsert CRC calculations
Date: 2005-05-16 11:12:55
Message-ID: 9EB50F1A91413F4FA63019487FCD251D113332@WEBBASEDDC.webbasedltd.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> -----Original Message-----
> From: Mark Cave-Ayland [mailto:m(dot)cave-ayland(at)webbased(dot)co(dot)uk]
> Sent: 16 May 2005 09:04
> To: 'Simon Riggs'
> Cc: 'Christopher Kings-Lynne'; 'Tom Lane'; 'Bruce Momjian';
> 'pgsql-hackers(at)postgresql(dot)org'
> Subject: RE: [HACKERS] Cost of XLogInsert CRC calculations

(cut)

> The program used to time the CRC64 calculation simply did the
> following:

(cut)

> 2) Fill the buffer with some repeatable values; in this case the
> algorithm used was the following:
>
> for (i = 0 ; i < 8192 ; i++ )
> {
> *data = (char )(i % 256);
> }

Sigh, so it would help if I had added the offset to the data pointer... ;)

for (i = 0 ; i < 8192 ; i++ )
{
*(data + i) = (char )(i % 256);
}

This now gives the following (correct) result on both platforms:
Win32: 1.8GHz P4, WinXP
Linux: 2.8GHz Xeon, FC1

Win32 UINT64: 0x782104059a01660 (crc0)
~158us
Win32 UINT32: 0x78210405 (crc1), 0x59a01660 (crc0) ~58us

FC1 UINT64: 0x782104059a01660 (crc0)
~76us
FC1 UINT32: 0x78210405 (crc1), 0x59a01660 (crc0)
~29us

Note that we still find that using the INT64_IS_BUSTED code is over 100%
quicker than the UINT64 code for CRC64 calculation, and I believe it is not
being used by default under Linux or Win32 for 32 bit platforms. Of course
Tom's suggestion of going for CRC32 across the board would hopefully solve
this entirely and bring the times down a little further too.

Kind regards,

Mark.

------------------------
WebBased Ltd
17 Research Way
Plymouth
PL6 8BT

T: +44 (0)1752 797131
F: +44 (0)1752 791023
W: http://www.webbased.co.uk

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2005-05-16 11:56:37 Re: bitmap scans, btree scans, and tid order
Previous Message Dmitriy Letuchy 2005-05-16 09:42:24 postgreSQL as deductive DBMS