From 8b2192a0b67bbcdadd62d00e1754f4d5aee9dd81 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 28 Jun 2024 00:27:53 +0100 Subject: [PATCH] Add a todo to rework the heap --- todo.org | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/todo.org b/todo.org index dc9fd37..1dc8e50 100644 --- a/todo.org +++ b/todo.org @@ -3,7 +3,23 @@ #+date: 2023-11-02 #+startup: noindent -* TODO Introduce error handling in base library :LIB: +* TODO Rework heap to use one allocation +The current approach for the heap is so: ++ Per call to ~malloc~, allocate a new ~page_t~ structure by + requesting memory from the operating system ++ Append the pointer to the ~page_t~ to a dynamic array of pointers + +In the worst case, per allocation call by the user the runtime must +request memory /twice/ from the operating system. For small scale +allocations of a few bytes this is especially wasteful. Furthermore +the actual heap usage of a program can seem unpredictable for a user +of the virtual machine, particularly in cases where the dynamic array +of pointers must resize to append a new allocation. + +I propose that the runtime has one massive allocation done at init +time for a sufficiently large buffer of bytes (call it =B=) which we +use as the underlying memory for the heap. +* TODO Deal with TODOs There is a large variety of TODOs about errors. Let's fix them! #+begin_src sh :exports results :results output verbatim replace find -type 'f' -regex ".*\.[ch]\(pp\)?" -exec grep -nH TODO "{}" ";"