Re: pgbench - add pseudo-random permutation function

Fabien COELHO <coelho@cri.ensmp.fr>

From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, Thomas Munro <thomas.munro@gmail.com>, Hironobu SUZUKI <hironobu@interdb.jp>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, David Steele <david@pgmasters.net>
Date: 2020-04-05T12:45:42Z
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.

> Attached is an attempt at improving things. I have added a explicit note and 
> hijacked an existing example to better illustrate the purpose of the 
> function.

A significant part of the complexity of the patch is the overflow-handling 
implementation of (a * b % c) for 64 bits integers.

However this implementation is probably never used because int128 bits are 
available and the one line implementation takes precedence, or the size is 
small enough (less than 48 bits) so that there are no overflows with the 
primes involved, thus the operation is done directly on 64 bits integers.

I could remove the implementation and replace it with a "not available on 
this architecture" message, which would seldom be triggered: you would 
have to use a 32 bits arch (?) and test against a table with about 262 
Trows, which I guess does not exists anywhere. This approach would remove 
about 40% of the code & comments.

Thougths?

-- 
Fabien.