Re: Hash twice - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Hash twice
Date
Msg-id CA+TgmoYB0L8oDLopPC81s63NGOvqzyaY4o_kRH09_wgEpJnWUw@mail.gmail.com
Whole thread Raw
In response to Hash twice  (Simon Riggs <simon@2ndQuadrant.com>)
Responses Re: Hash twice
List pgsql-hackers
On Sat, Jan 12, 2013 at 11:39 AM, Simon Riggs <simon@2ndquadrant.com> wrote:
> Lock code says it calculates "hash value once and then pass around as needed".
>
> But it actually calculates it twice for new locks.
>
> Trivial patch attached to make it follow the comments in
> LockTagHashCode and save a few cycles.

Hmm.  This is a nice idea, but it doesn't look right to me, because
you're searching LockMethodLocalHash with a hash code intended to be
used in LockMethodLockHash, and the two hashing schemes are not
compatible, because the former is hashing a LOCALLOCKTAG, and the
latter is hashing a LOCKTAG, and both are just using tag_hash.

On the flip side if I'm wrong and the hashing schemes are compatible,
there are other places in the file where the same trick could be
employed.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: erroneous restore into pg_catalog schema
Next
From: Simon Riggs
Date:
Subject: Re: Hash twice