pgbench - add pseudo-random permutation function

Fabien COELHO <coelho@cri.ensmp.fr>

From: Fabien COELHO <coelho@cri.ensmp.fr>
To: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2018-07-28T14:03:49Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. pgbench: Function to generate random permutations.

  2. Add basic support for using the POPCNT and SSE4.2s LZCNT opcodes

  3. Further improve code for probing the availability of ARM CRC instructions.

Attachments

Hello,

This patch adds a pseudo-random permutation function to pgbench. It allows 
to mix non uniform random keys to avoid trivial correlations between 
neighboring values, hence between pages.

The function is a simplistic form of encryption adapted to any size, using 
a few iterations of scramble and scatter phases. The result is not 
cryptographically convincing, nor even statistically, but it is quite 
inexpensive and achieves the desired result. A computation costs 0.22 µs 
per call on my laptop, about three times the cost of a simple function.

Alternative designs, such as iterating over an actual encryption function 
or using some sbox, would lead to much more costly solutions and complex 
code.

I also join a few scripts I used for testing.

-- 
Fabien.