Rename BufferAccessStrategyData.ring_size to nbuffers
The new name better reflects what the field is - the size of the buffers[] array. ring_size sounded more like it is in units of bytes. An upcoming commit allows a BufferAccessStrategy of custom sizes, so it seems relevant to improve this beforehand. Author: Melanie Plageman Reviewed-by: David Rowley Discussion: https://postgr.es/m/CAAKRu_YefVbhg4rAxU2frYFdTap61UftH-kUNQZBvAs%2BYK81Zg%40mail.gmail.com
This commit is contained in:
parent
4830f10243
commit
8d928e3a9f
@ -74,7 +74,7 @@ typedef struct BufferAccessStrategyData
|
|||||||
/* Overall strategy type */
|
/* Overall strategy type */
|
||||||
BufferAccessStrategyType btype;
|
BufferAccessStrategyType btype;
|
||||||
/* Number of elements in buffers[] array */
|
/* Number of elements in buffers[] array */
|
||||||
int ring_size;
|
int nbuffers;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Index of the "current" slot in the ring, ie, the one most recently
|
* Index of the "current" slot in the ring, ie, the one most recently
|
||||||
@ -541,7 +541,7 @@ BufferAccessStrategy
|
|||||||
GetAccessStrategy(BufferAccessStrategyType btype)
|
GetAccessStrategy(BufferAccessStrategyType btype)
|
||||||
{
|
{
|
||||||
BufferAccessStrategy strategy;
|
BufferAccessStrategy strategy;
|
||||||
int ring_size;
|
int nbuffers;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Select ring size to use. See buffer/README for rationales.
|
* Select ring size to use. See buffer/README for rationales.
|
||||||
@ -556,13 +556,13 @@ GetAccessStrategy(BufferAccessStrategyType btype)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
case BAS_BULKREAD:
|
case BAS_BULKREAD:
|
||||||
ring_size = 256 * 1024 / BLCKSZ;
|
nbuffers = 256 * 1024 / BLCKSZ;
|
||||||
break;
|
break;
|
||||||
case BAS_BULKWRITE:
|
case BAS_BULKWRITE:
|
||||||
ring_size = 16 * 1024 * 1024 / BLCKSZ;
|
nbuffers = 16 * 1024 * 1024 / BLCKSZ;
|
||||||
break;
|
break;
|
||||||
case BAS_VACUUM:
|
case BAS_VACUUM:
|
||||||
ring_size = 256 * 1024 / BLCKSZ;
|
nbuffers = 256 * 1024 / BLCKSZ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -572,16 +572,16 @@ GetAccessStrategy(BufferAccessStrategyType btype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure ring isn't an undue fraction of shared buffers */
|
/* Make sure ring isn't an undue fraction of shared buffers */
|
||||||
ring_size = Min(NBuffers / 8, ring_size);
|
nbuffers = Min(NBuffers / 8, nbuffers);
|
||||||
|
|
||||||
/* Allocate the object and initialize all elements to zeroes */
|
/* Allocate the object and initialize all elements to zeroes */
|
||||||
strategy = (BufferAccessStrategy)
|
strategy = (BufferAccessStrategy)
|
||||||
palloc0(offsetof(BufferAccessStrategyData, buffers) +
|
palloc0(offsetof(BufferAccessStrategyData, buffers) +
|
||||||
ring_size * sizeof(Buffer));
|
nbuffers * sizeof(Buffer));
|
||||||
|
|
||||||
/* Set fields that don't start out zero */
|
/* Set fields that don't start out zero */
|
||||||
strategy->btype = btype;
|
strategy->btype = btype;
|
||||||
strategy->ring_size = ring_size;
|
strategy->nbuffers = nbuffers;
|
||||||
|
|
||||||
return strategy;
|
return strategy;
|
||||||
}
|
}
|
||||||
@ -615,7 +615,7 @@ GetBufferFromRing(BufferAccessStrategy strategy, uint32 *buf_state)
|
|||||||
|
|
||||||
|
|
||||||
/* Advance to next ring slot */
|
/* Advance to next ring slot */
|
||||||
if (++strategy->current >= strategy->ring_size)
|
if (++strategy->current >= strategy->nbuffers)
|
||||||
strategy->current = 0;
|
strategy->current = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user