From ba7161d6a3156a966c21ea3e06168bdac9803819 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 28 Jun 2025 14:18:59 -0400 Subject: Greatly increase the maximum free space allocated when growing lists (from 63 -> 281,474,976,710,655) to fix degenerate performance when appending to large lists. --- src/stdlib/datatypes.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/stdlib/datatypes.h') diff --git a/src/stdlib/datatypes.h b/src/stdlib/datatypes.h index 77c09ddb..135fb811 100644 --- a/src/stdlib/datatypes.h +++ b/src/stdlib/datatypes.h @@ -7,12 +7,13 @@ #include #include -#define LIST_LENGTH_BITS 42 -#define LIST_FREE_BITS 6 +#define LIST_LENGTH_BITS 64 +#define LIST_FREE_BITS 48 +#define LIST_ATOMIC_BITS 1 #define LIST_REFCOUNT_BITS 3 #define LIST_STRIDE_BITS 12 -#define MAX_FOR_N_BITS(N) ((1<<(N))-1) +#define MAX_FOR_N_BITS(N) ((1L<<(N))-1L) #define LIST_MAX_STRIDE MAX_FOR_N_BITS(LIST_STRIDE_BITS-1) #define LIST_MIN_STRIDE (~MAX_FOR_N_BITS(LIST_STRIDE_BITS-1)) #define LIST_MAX_DATA_REFCOUNT MAX_FOR_N_BITS(LIST_REFCOUNT_BITS) @@ -42,8 +43,8 @@ typedef struct { // bit arithmetic to extract the necessary values, which is cheaper than // spilling onto the stack and needing to retrieve data from the stack. int64_t length:LIST_LENGTH_BITS; - uint8_t free:LIST_FREE_BITS; - bool atomic:1; + uint64_t free:LIST_FREE_BITS; + bool atomic:LIST_ATOMIC_BITS; uint8_t data_refcount:LIST_REFCOUNT_BITS; int16_t stride:LIST_STRIDE_BITS; } List_t; -- cgit v1.2.3