Size maxBlockSize; /* maximum block size */
Size nextBlockSize; /* next block size to allocate */
Size allocChunkLimit; /* effective chunk size limit */
- AllocBlock keeper; /* if not NULL, keep this block over resets */
+ AllocBlock keeper; /* keep this block over resets */
} AllocSetContext;
typedef AllocSetContext *AllocSet;
* AllocChunk
* The prefix of each piece of memory in an AllocBlock
*
- * NB: this MUST match StandardChunkHeader as defined by utils/memutils.h.
+ * NB: The last element of this structure MUST be a StandardChunkHeader.
*/
typedef struct AllocChunkData
{
- /* aset is the owning aset if allocated, or the freelist link if free */
- void *aset;
- /* size is always the size of the usable space in the chunk */
- Size size;
#ifdef MEMORY_CONTEXT_CHECKING
/* when debugging memory usage, also store actual requested size */
/* this is zero in a free chunk */
Size requested_size;
#endif
+ StandardChunkHeader standard_header;
} AllocChunkData;
/*
};
/*
- * Whenever we allocate an AllocSetContext, we pad it out to 2kB and use
+ * Whenever we allocate an AllocSetContext, we pad it out to 1kB and use
* the space not required by the context itself to store the context name
- * and the first few allocations. (The AllocSetContext structure itself
- * is ~200 bytes, so making this only 1kB would leave barely any room for
- * actual allocations.)
+ * and the first few allocations.
*/
-#define ALLOCSET_PADDED_SIZE 2048
+#define ALLOCSET_PADDED_SIZE 1024
typedef union AllocSetContextPadded
{
AllocSetContext context;
else if (AllocSetFreelist != NULL)
{
/*
- * An ordinary AllocSetPadded is adequate for our purposes, and
+ * An ordinary AllocSetContextPadded is adequate for our purposes, and
* there's one available on the freelist. Pop it off and use it!
* This is expected to be the normal case.
*/
int i;
/*
- * An ordinary AllocSetPadded is adequate for our purposes, but
+ * An ordinary AllocSetContextPadded is adequate for our purposes, but
* there aren't any on the freelist. Allocate space for a bunch
* more contexts, put all but the first one on the freelist, and
* use the first one. This will happen when creating
* On systems with 8-byte alignment, we allow 29 bits for the context ID and
* 32 bits for the size. This allows for up to half a billion context IDs and
* sizes of up to 1 byte less than 4GB. Thus, extended headers should
- * almost never be required. On systems with 4-byte alignment, we allow 11
- * bits for the context ID and 18 bits for the size, which allows for up to
- * 2048 possible context IDs and allocations of up to 1 byte less than 256kB.
+ * almost never be required. On systems with 4-byte alignment, we allow 20
+ * bits for the context ID and 19 bits for the size, which allows for up to
+ * 1 million possible context IDs and allocations of up to 511 bytes.
* This should be good enough that most allocations won't need an extended
* header, but some will.
*/
#define CHUNK_SIZE_BITS 32
#else
typedef uint32 chunk_unsigned;
-#define CHUNK_CONTEXT_ID_BITS 11
-#define CHUNK_SIZE_BITS 18
+#define CHUNK_CONTEXT_ID_BITS 20
+#define CHUNK_SIZE_BITS 9
#endif
/* Context type codes; must be less than 1 << CHUNK_CONTEXT_TYPE_BITS. */