Skip to content

Commit

Permalink
FEAT: fine tune memory pool sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Dec 6, 2022
1 parent fb8a03a commit 36828a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/m-pools.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
***********************************************************************/
const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
{
{8, 256}, // 0-8 Small string pool
{8, 512}, // 0-8 Small string pool

MOD_POOL( 1, 256), // 9-16 (when REBVAL is 16)
MOD_POOL( 1, 1024), // 9-16 (when REBVAL is 16)
MOD_POOL( 2, 512), // 17-32 - Small series (x 16)
MOD_POOL( 3, 1024), // 33-64
MOD_POOL( 4, 512),
Expand All @@ -96,12 +96,12 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
MOD_POOL(20, 32), // 321 - Mid-size series (x 64)
MOD_POOL(24, 16), // 385
MOD_POOL(28, 16), // 449
MOD_POOL(32, 8), // 513
MOD_POOL(LAST_SMALL_SIZE, 16), // 513

DEF_POOL(MEM_BIG_SIZE, 16), // 1K - Large series (x 1024)
DEF_POOL(MEM_BIG_SIZE*2, 8), // 2K
DEF_POOL(MEM_BIG_SIZE*3, 4), // 3K
DEF_POOL(MEM_BIG_SIZE*4, 4), // 4K
DEF_POOL(MEM_BIG_SIZE, 16), // 1K - Large series (x 1024)
DEF_POOL(MEM_BIG_SIZE*2, 16), // 2K
DEF_POOL(MEM_BIG_SIZE*3, 4), // 3K
DEF_POOL(MEM_BIG_SIZE*4, 8), // 4K

DEF_POOL(sizeof(REBSER), 4096), // Series headers
DEF_POOL(sizeof(REBGOB), 128), // Gobs
Expand Down Expand Up @@ -168,7 +168,7 @@ const REBPOOLSPEC Mem_Pool_Spec[MAX_POOLS] =
PG_Pool_Map = Make_Mem((4 * MEM_BIG_SIZE) + 4); // extra
n = 9; // sizes 0 - 8 are pool 0
for (; n <= 16 * MEM_MIN_SIZE; n++) PG_Pool_Map[n] = MEM_TINY_POOL + ((n-1) / MEM_MIN_SIZE);
for (; n <= 32 * MEM_MIN_SIZE; n++) PG_Pool_Map[n] = MEM_SMALL_POOLS-4 + ((n-1) / (MEM_MIN_SIZE * 4));
for (; n <= LAST_SMALL_SIZE * MEM_MIN_SIZE; n++) PG_Pool_Map[n] = MEM_SMALL_POOLS-4 + ((n-1) / (MEM_MIN_SIZE * 4));
for (; n <= 4 * MEM_BIG_SIZE; n++) PG_Pool_Map[n] = MEM_MID_POOLS + ((n-1) / MEM_BIG_SIZE);
}

Expand Down
7 changes: 7 additions & 0 deletions src/include/sys-mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ typedef void *REBNOD; // Just used for linking free nodes
#define MEM_MIN_SIZE sizeof(REBVAL)
#define MEM_BIG_SIZE 1024

#ifdef __LP64__
// on 64bit system the value 32 would result in size 1024 bytes, which is already first BIG pool
#define LAST_SMALL_SIZE 30
#else
#define LAST_SMALL_SIZE 32
#endif

#define MEM_BALLAST 3000000

// Disable GC - Only necessary if DO_NEXT with non-referenced series.
Expand Down

0 comments on commit 36828a2

Please sign in to comment.