Skip site navigation (1) Skip section navigation (2)

Re: New CRC algorithm: Slicing by 8

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
Cc: "PGSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: New CRC algorithm: Slicing by 8
Date: 2006-10-25 04:30:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
"Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com> writes:
> On 10/23/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us > wrote:
>> I didn't particularly trust the timing calculations in your benchmark
>> program,

>     Any particular reason? (why and what did you doubt in it?).

Well, the specific thing that set off my bogometer was

#define TV_DIFF_MILLI(tv1, tv2) ((tv2.tv_sec*1000+((tv2.tv_usec)/1000))-(tv1.tv_sec*1000+((tv1.tv_usec)/1000)))

which is going to have overflow problems on any platform where tv_sec
isn't a 64-bit type (which is still all of 'em AFAIK).  But more
generally, your test is timing a CRC across 100 4Kb segments, which
isn't representative of PG's usage of CRCs.  I don't think there are
any XLogWrite calls that have more than about 5 segments, and in most
cases those segments contain a few dozen bytes not a few K.  So you
need to be looking at much shorter loop runs.

The test case I proposed uses timing code that I trusted (borrowed from
long-established coding in postgres.c), and tests loop lengths that are
somewhat representative for PG, but it is still biased in favor of slice8
because it repeats the CRC calculations consecutively without any other
activity --- presumably this fact creates a bias for a method that needs
more L2 cache space over one that doesn't need so much.  I'd have tried
harder to make an unbiased test case if this version had showed slice8 as
competitive, but so far it seems that on a majority of current CPUs and
compilers it's not competitive.

			regards, tom lane

In response to

pgsql-hackers by date

Next:From: Tom LaneDate: 2006-10-25 05:06:41
Subject: Re: Reg external sorting alogrithm
Previous:From: Steve AtkinsDate: 2006-10-25 04:27:14
Subject: Re: [DOCS] Replication documentation addition

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group