Re: Block-level CRC checks

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <greg(dot)stark(at)enterprisedb(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Block-level CRC checks
Date: 2008-11-12 14:08:13
Message-ID: 20081112140813.GB4535@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Martijn van Oosterhout wrote:

> If you're going to look at the line pointers anyway, couldn't you just
> do it in one pass, like:
>
> n = 0
> next = &tuple[n].hintbits
> pos = 0
> while pos < BLOCK_SIZE:
> if pos == next:
> CRC_ADD( block[pos] & mask )
> n++
> next = &tuple[n].hintbits # If n == numtups, next = BLOCK_SIZE
> else:
> CRC_ADD( block[pos]
> pos++

For this to work, we would have to create two (or more) versions of the
calculate checksum macro, one for heap pages and other for other pages.
I'm not sure how bad is that. The bit that's worse is that we'd need to
have external knowledge of what kind of page we're talking about (i.e.
FlushBuffer would need to know whether a page is heap or another kind).

However, your idea suggests something else that we could do to improve
the patch: skip the ItemId->lp_flags during the CRC calculation. This
would mean we wouldn't need to WAL-log those. The problem with that is
that lp_flags are only 2 bits, so we would need to iterate zeroing them
and restore them after CRC_COMP() instead of simply skipping.

The immediately useful information arising from your note is that I
noticed I'm calling a heap routine on non-heap pages, because of setting
PD_UNLOGGED_CHANGE for ItemId flags on index pages.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-11-12 14:16:07 Re: Block-level CRC checks
Previous Message Peter Eisentraut 2008-11-12 13:24:20 Re: Distinct types