mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Revert attempts to use POPCNT etc instructions
This reverts commitsfc6c72747a
,109de05cbb
,d0b4663c23
and711bab1e4d
. Somebody will have to try harder before submitting this patch again. I've spent entirely too much time on it already, and the #ifdef maze yet to be written in order for it to build at all got on my nerves. The amount of work needed to get a platform-specific performance improvement that's barely above the noise level is not worth it.
This commit is contained in:
@ -89,12 +89,12 @@
|
||||
#include "access/visibilitymap.h"
|
||||
#include "access/xlog.h"
|
||||
#include "miscadmin.h"
|
||||
#include "port/pg_bitutils.h"
|
||||
#include "storage/bufmgr.h"
|
||||
#include "storage/lmgr.h"
|
||||
#include "storage/smgr.h"
|
||||
#include "utils/inval.h"
|
||||
|
||||
|
||||
/*#define TRACE_VISIBILITYMAP */
|
||||
|
||||
/*
|
||||
@ -115,9 +115,43 @@
|
||||
#define HEAPBLK_TO_MAPBYTE(x) (((x) % HEAPBLOCKS_PER_PAGE) / HEAPBLOCKS_PER_BYTE)
|
||||
#define HEAPBLK_TO_OFFSET(x) (((x) % HEAPBLOCKS_PER_BYTE) * BITS_PER_HEAPBLOCK)
|
||||
|
||||
/* Masks for bit counting bits in the visibility map. */
|
||||
#define VISIBLE_MASK64 0x5555555555555555 /* The lower bit of each bit pair */
|
||||
#define FROZEN_MASK64 0xaaaaaaaaaaaaaaaa /* The upper bit of each bit pair */
|
||||
/* tables for fast counting of set bits for visible and frozen */
|
||||
static const uint8 number_of_ones_for_visible[256] = {
|
||||
0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2,
|
||||
1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
|
||||
0, 1, 0, 1, 1, 2, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2,
|
||||
1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 2, 3,
|
||||
1, 2, 1, 2, 2, 3, 2, 3, 1, 2, 1, 2, 2, 3, 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2, 2, 3, 3, 2, 2, 3, 3,
|
||||
1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
|
||||
1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
|
||||
2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4,
|
||||
2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4,
|
||||
1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
|
||||
1, 1, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 2, 2, 3, 3,
|
||||
2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4,
|
||||
2, 2, 3, 3, 2, 2, 3, 3, 3, 3, 4, 4, 3, 3, 4, 4
|
||||
};
|
||||
|
||||
/* prototypes for internal routines */
|
||||
static Buffer vm_readbuf(Relation rel, BlockNumber blkno, bool extend);
|
||||
@ -374,16 +408,18 @@ void
|
||||
visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_frozen)
|
||||
{
|
||||
BlockNumber mapBlock;
|
||||
BlockNumber nvisible = 0;
|
||||
BlockNumber nfrozen = 0;
|
||||
|
||||
/* all_visible must be specified */
|
||||
Assert(all_visible);
|
||||
|
||||
*all_visible = 0;
|
||||
if (all_frozen)
|
||||
*all_frozen = 0;
|
||||
|
||||
for (mapBlock = 0;; mapBlock++)
|
||||
{
|
||||
Buffer mapBuffer;
|
||||
uint64 *map;
|
||||
unsigned char *map;
|
||||
int i;
|
||||
|
||||
/*
|
||||
@ -400,30 +436,17 @@ visibilitymap_count(Relation rel, BlockNumber *all_visible, BlockNumber *all_fro
|
||||
* immediately stale anyway if anyone is concurrently setting or
|
||||
* clearing bits, and we only really need an approximate value.
|
||||
*/
|
||||
map = (uint64 *) PageGetContents(BufferGetPage(mapBuffer));
|
||||
map = (unsigned char *) PageGetContents(BufferGetPage(mapBuffer));
|
||||
|
||||
StaticAssertStmt(MAPSIZE % sizeof(uint64) == 0,
|
||||
"unsupported MAPSIZE");
|
||||
if (all_frozen == NULL)
|
||||
for (i = 0; i < MAPSIZE; i++)
|
||||
{
|
||||
for (i = 0; i < MAPSIZE / sizeof(uint64); i++)
|
||||
nvisible += pg_popcount64(map[i] & VISIBLE_MASK64);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < MAPSIZE / sizeof(uint64); i++)
|
||||
{
|
||||
nvisible += pg_popcount64(map[i] & VISIBLE_MASK64);
|
||||
nfrozen += pg_popcount64(map[i] & FROZEN_MASK64);
|
||||
}
|
||||
*all_visible += number_of_ones_for_visible[map[i]];
|
||||
if (all_frozen)
|
||||
*all_frozen += number_of_ones_for_frozen[map[i]];
|
||||
}
|
||||
|
||||
ReleaseBuffer(mapBuffer);
|
||||
}
|
||||
|
||||
*all_visible = nvisible;
|
||||
if (all_frozen)
|
||||
*all_frozen = nfrozen;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user