aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-12 00:20:25 +0000
committergingerBill <bill@gingerbill.org>2023-01-12 00:20:25 +0000
commite9cfe698bad140fcfb6dda6baf1e8b2e00e52003 (patch)
tree8d0f1e43967f065fdbd8e7fb3b9a00e3005cce2d /src
parent5fa66ac6a8d8624fdb078d459ff58c45fa2dae9a (diff)
Make the `heap_allocator` just be the `permanent_allocator`
This improves the speed of the compiler with very little memory increase (which surprised me, Ginger Bill)
Diffstat (limited to 'src')
-rw-r--r--src/build_settings.cpp1
-rw-r--r--src/common_memory.cpp9
-rw-r--r--src/main.cpp13
-rw-r--r--src/microsoft_craziness.h6
4 files changed, 17 insertions, 12 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp
index 609a010de..0640c7982 100644
--- a/src/build_settings.cpp
+++ b/src/build_settings.cpp
@@ -1411,7 +1411,6 @@ gb_internal bool init_build_paths(String init_filename) {
if ((bc->command_kind & Command__does_build) && (!bc->ignore_microsoft_magic)) {
// NOTE(ic): It would be nice to extend this so that we could specify the Visual Studio version that we want instead of defaulting to the latest.
Find_Result find_result = find_visual_studio_and_windows_sdk();
- defer (mc_free_all());
if (find_result.windows_sdk_version == 0) {
gb_printf_err("Windows SDK not found.\n");
diff --git a/src/common_memory.cpp b/src/common_memory.cpp
index 4c77521e1..940e79f4b 100644
--- a/src/common_memory.cpp
+++ b/src/common_memory.cpp
@@ -306,10 +306,11 @@ gb_internal gbAllocator temporary_allocator() {
gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc);
gb_internal gbAllocator heap_allocator(void) {
- gbAllocator a;
- a.proc = heap_allocator_proc;
- a.data = nullptr;
- return a;
+ return arena_allocator(&permanent_arena);
+ // gbAllocator a;
+ // a.proc = heap_allocator_proc;
+ // a.data = nullptr;
+ // return a;
}
diff --git a/src/main.cpp b/src/main.cpp
index 4e8dfaf75..eacce253d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1716,6 +1716,16 @@ gb_internal void show_timings(Checker *c, Timings *t) {
timings_print_all(t);
+ if (build_context.show_more_timings) {
+ #if defined(GB_SYSTEM_WINDOWS)
+ PROCESS_MEMORY_COUNTERS p = {sizeof(p)};
+ if (GetProcessMemoryInfo(GetCurrentProcess(), &p, sizeof(p))) {
+ gb_printf("\n");
+ gb_printf("Peak Memory Size: %.3f MiB\n", (cast(f64)p.PeakWorkingSetSize) / cast(f64)(1024ull * 1024ull));
+ }
+ #endif
+ }
+
if (!(build_context.export_timings_format == TimingsExportUnspecified)) {
timings_export_all(t, c, true);
}
@@ -2481,14 +2491,13 @@ int main(int arg_count, char const **arg_ptr) {
usage(make_string_c(arg_ptr[0]));
return 1;
}
+ virtual_memory_init();
timings_init(&global_timings, str_lit("Total Time"), 2048);
defer (timings_destroy(&global_timings));
MAIN_TIME_SECTION("initialization");
- virtual_memory_init();
-
init_string_interner();
init_global_error_collector();
init_keyword_hash_table();
diff --git a/src/microsoft_craziness.h b/src/microsoft_craziness.h
index 4e6182e07..899583143 100644
--- a/src/microsoft_craziness.h
+++ b/src/microsoft_craziness.h
@@ -45,7 +45,7 @@
//
// Here is the API you need to know about:
//
-gb_global gbAllocator mc_allocator = heap_allocator();
+gb_global gbAllocator mc_allocator = permanent_allocator();
struct Find_Result {
int windows_sdk_version; // Zero if no Windows SDK found.
@@ -91,10 +91,6 @@ gb_internal void mc_free(String16 str) {
if (str.len) gb_free(mc_allocator, str.text);
}
-gb_internal void mc_free_all() {
- gb_free_all(mc_allocator);
-}
-
typedef struct _MC_Find_Data {
DWORD file_attributes;
String filename;