aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/datatypes.h
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-06-28 14:18:59 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-06-28 14:18:59 -0400
commitba7161d6a3156a966c21ea3e06168bdac9803819 (patch)
tree0fd65f8513d1ab378be83c79a4ac1db74f38df81 /src/stdlib/datatypes.h
parent8a4d5dc57b14e7c947c25970bb4d4f4ef91450f4 (diff)
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.
Diffstat (limited to 'src/stdlib/datatypes.h')
-rw-r--r--src/stdlib/datatypes.h11
1 files changed, 6 insertions, 5 deletions
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 <stdint.h>
#include <time.h>
-#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;