Commit: 54be90c3fc475444f115e8d5c87f4b743f775c35
Parent: cb15470580aa77a7a4baef7af091909d9905d877
Author: Randy Palamar
Date: Sat, 30 Nov 2024 00:20:55 -0700
decrease the render threads stack size
Nothing is really being allocated on the stack in that thread and
we are not and don't want to ever deeply nest functions there.
Diffstat:
5 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/debug.c b/debug.c
@@ -18,7 +18,7 @@ dump_lines_to_file(Term *t)
size line_count = MIN(256, tv->lines.filled);
Arena temp_arena = t->arena_for_frame;
- Stream out = stream_alloc(&temp_arena, 1 * MEGABYTE);
+ Stream out = stream_alloc(&temp_arena, MB(1));
iv2 tsize = {.w = t->size.w, .h = t->size.h};
iv2 wsize = {.w = t->gl.window_size.w, .h = t->gl.window_size.h};
diff --git a/platform_linux_x11.c b/platform_linux_x11.c
@@ -358,7 +358,7 @@ i32
main(i32 argc, char *argv[], char *envp[])
{
linux_ctx.platform_memory = arena_from_memory_block(linux_block_alloc(MB(2)));
- linux_ctx.error_stream = stream_alloc(&linux_ctx.platform_memory, MEGABYTE / 4);
+ linux_ctx.error_stream = stream_alloc(&linux_ctx.platform_memory, KB(256));
iv2 cells = {.x = -1, .y = -1};
@@ -403,7 +403,7 @@ main(i32 argc, char *argv[], char *envp[])
linux_ctx.error_stream.widx = 0;
}
- struct stack_base *render_stack = new_stack(MB(4));
+ struct stack_base *render_stack = new_stack(KB(256));
render_stack->entry = linux_render_thread_entry;
clone_thread(render_stack);
diff --git a/tests/test.c b/tests/test.c
@@ -331,11 +331,11 @@ static TEST_FN(working_ringbuffer)
int
main(void)
{
- Arena memory = arena_from_memory_block(linux_block_alloc(32 * MEGABYTE));
+ Arena memory = arena_from_memory_block(linux_block_alloc(MB(32)));
Term term = {0};
u32 failure_count = 0;
- Stream log = stream_alloc(&memory, 4 * MEGABYTE);
+ Stream log = stream_alloc(&memory, MB(4));
for (u32 i = 0; i < ARRAY_COUNT(term.saved_cursors); i++) {
cursor_reset(&term);
cursor_move_to(&term, 0, 0);
@@ -351,8 +351,8 @@ main(void)
/* TODO: should probably be some odd size */
term.size = (iv2){.w = 80, .h = 24};
- term.views[0].fb.backing_store = memory_block_from_arena(&memory, 2 * MEGABYTE);
- term.views[1].fb.backing_store = memory_block_from_arena(&memory, 2 * MEGABYTE);
+ term.views[0].fb.backing_store = memory_block_from_arena(&memory, MB(2));
+ term.views[1].fb.backing_store = memory_block_from_arena(&memory, MB(2));
initialize_framebuffer(&term.views[0].fb, term.size);
initialize_framebuffer(&term.views[1].fb, term.size);
diff --git a/vtgl.c b/vtgl.c
@@ -148,7 +148,7 @@ reload_all_shaders(TerminalMemory *memory)
TempArena temp_memory = begin_temp_arena(&t->arena_for_frame);
- Stream fs_path = stream_alloc(&t->arena_for_frame, 4 * KILOBYTE);
+ Stream fs_path = stream_alloc(&t->arena_for_frame, KB(4));
stream_push_s8(&fs_path, g_shader_path_prefix);
if (fs_path.widx && fs_path.buf[fs_path.widx - 1] != platform->path_separator)
stream_push_byte(&fs_path, platform->path_separator);
@@ -311,7 +311,7 @@ make_render_ctx(Arena *a, GLCtx *gl, FontAtlas *fa)
result.gl = gl;
result.fa = fa;
result.rpb = alloc(a, RenderPushBuffer, 1);
- result.a = sub_arena(a, 4 * MEGABYTE);
+ result.a = sub_arena(a, MB(4));
return result;
}
@@ -1083,8 +1083,8 @@ DEBUG_EXPORT VTGL_INITIALIZE_FN(vtgl_initialize)
memory->platform_api.allocate_ring_buffer(&t->views[1].log, ALT_BACKLOG_SIZE);
line_buf_alloc(&t->views[1].lines, &a, t->views[1].log.buf, t->cursor.style, ALT_BACKLOG_LINES);
- t->views[0].fb.backing_store = memory_block_from_arena(&a, 2 * MEGABYTE);
- t->views[1].fb.backing_store = memory_block_from_arena(&a, 2 * MEGABYTE);
+ t->views[0].fb.backing_store = memory_block_from_arena(&a, MB(2));
+ t->views[1].fb.backing_store = memory_block_from_arena(&a, MB(2));
t->gl.glyph_bitmap_dim = monitor_size;
init_fonts(&t->fa, &a, t->gl.glyph_bitmap_dim);
@@ -1125,8 +1125,8 @@ DEBUG_EXPORT VTGL_INITIALIZE_FN(vtgl_initialize)
a.beg = path.buf + path.widx;
}
- t->error_stream = stream_alloc(&a, MEGABYTE / 4);
- t->saved_title = stream_alloc(&a, 16 * KILOBYTE);
+ t->error_stream = stream_alloc(&a, KB(256));
+ t->saved_title = stream_alloc(&a, KB(16));
t->arena_for_frame = a;
t->child = child;
diff --git a/vtgl.h b/vtgl.h
@@ -28,8 +28,8 @@
#endif
#define PI 3.1415926535897932384f
-#define KILOBYTE (1024ULL)
-#define MEGABYTE (1024ULL * 1024ULL)
+
+#define KB(a) ((a) << 10ULL)
#define MB(a) ((a) << 20ULL)
#define ARRAY_COUNT(a) (sizeof(a) / sizeof(*a))
@@ -53,10 +53,10 @@
/* NOTE: GLFW does not sequentially number keys so switch statement will never be optimized */
#define ENCODE_KEY(action, mod, key) (((action) << 24) | ((mod) << 16) | ((key) & 0xFFFF))
-#define BACKLOG_SIZE (16 * MEGABYTE)
+#define BACKLOG_SIZE (MB(16))
#define BACKLOG_LINES (8192UL)
-#define ALT_BACKLOG_SIZE (2 * MEGABYTE)
+#define ALT_BACKLOG_SIZE (MB(2))
#define ALT_BACKLOG_LINES (1024UL)
#define I64_MIN INT64_MIN