Re: [PATCH v4] Avoid manual shift-and-test logic in AllocSetFreeIndex

From: pg(at)thetdh(dot)com
To: pgsql-hackers(at)postgresql(dot)org
Cc: pg1(at)thetdh(dot)com
Subject: Re: [PATCH v4] Avoid manual shift-and-test logic in AllocSetFreeIndex
Date: 2009-07-21 13:10:45
Message-ID: W8012529423134111248181845@webmail36
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Normally I'd try a small lookup table (1-byte index to 1-byte value) in this case. But if the bitscan instruction were even close in performance, it'd be preferable, due to its more-reliable caching behavior; it should be possible to capture this at code-configuration time (aligned so as to produce an optimal result for each test case; see below).

The specific code for large-versus-small testing would be useful; did I overlook it?

Note that instruction alignment with respect to words is not the only potential instruction-alignment issue. In the past, when optimizing code to an extreme, I've run into cache-line issues where a small change that should've produced a small improvement resulted in a largish performance loss, without further work. Lookup tables can have an analogous issue; this could, in a simplistic test, explain an anomalous large-better-than-small result, if part of the large lookup table remains cached. (Do any modern CPUs attempt to address this??) This is difficult to tune in a multiplatform code base, so the numbers in a particular benchmark do not tell the whole tale; you'd need to make a judgment call, and perhaps to allow a code-configuration override.

David Hudson

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2009-07-21 13:13:41 Re: Sampling profiler updated
Previous Message Dickson S. Guedes 2009-07-21 12:23:25 Re: Duplicate key value error