From e282397bf0f1d5ce5d46053381eba07dfa09f929 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Tue, 7 May 2024 01:34:43 -0400 Subject: [PATCH] Nvm, took me way to long to realize the string cache needs a different hastable This hashtable is not tolerant over going 'over capacity'. I have to eventually swap to another solution similar to Ryans linear probing for string caching. For now I'll just abuse ram with an oversized table. --- code/font_provider.odin | 2 +- code/grime_hashmap_zpl.odin | 2 +- code/grime_memory_tracker.odin | 4 ++-- code/grime_pool_allocator.odin | 2 +- code/grime_string_interning.odin | 3 +-- code/tick_update.odin | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/code/font_provider.odin b/code/font_provider.odin index 0751754..9b3f26d 100644 --- a/code/font_provider.odin +++ b/code/font_provider.odin @@ -8,7 +8,7 @@ import "core:os" import rl "vendor:raylib" -Font_Largest_Px_Size :: 96 +Font_Largest_Px_Size :: 32 Font_Size_Interval :: 2 diff --git a/code/grime_hashmap_zpl.odin b/code/grime_hashmap_zpl.odin index f3ecfca..60f9063 100644 --- a/code/grime_hashmap_zpl.odin +++ b/code/grime_hashmap_zpl.odin @@ -116,7 +116,7 @@ zpl_hmap_rehash :: proc( ht : ^ HMapZPL( $ Type ), new_num : u64 ) -> AllocatorE { profile(#procedure) // For now the prototype should never allow this to happen. - // ensure( false, "ZPL HMAP IS REHASHING" ) + ensure( false, "ZPL HMAP IS REHASHING" ) last_added_index : i64 new_ht, init_result := zpl_hmap_init_reserve( Type, ht.hashes.backing, new_num, ht.hashes.dbg_name ) diff --git a/code/grime_memory_tracker.odin b/code/grime_memory_tracker.odin index ff9e9b9..ac97853 100644 --- a/code/grime_memory_tracker.odin +++ b/code/grime_memory_tracker.odin @@ -10,9 +10,9 @@ MemoryTracker :: struct { entries : Array(MemoryTrackerEntry), } -Track_Memory :: true +Track_Memory :: false -tracker_msg_buffer : [Kilobyte * 64]u8 +tracker_msg_buffer : [Kilobyte * 16]u8 memtracker_clear :: proc ( tracker : MemoryTracker ) { when ! Track_Memory { diff --git a/code/grime_pool_allocator.odin b/code/grime_pool_allocator.odin index 8b53ba3..d7ba31d 100644 --- a/code/grime_pool_allocator.odin +++ b/code/grime_pool_allocator.odin @@ -177,7 +177,7 @@ pool_grab :: proc( pool : Pool, zero_memory := false ) -> ( block : []byte, allo alloc_error = .None // Check the free-list first for a block - if pool.free_list_head != nil && false // There is a very nasty memory bug with free-lists I need to solve before they can be used. + if pool.free_list_head != nil { head := & pool.free_list_head diff --git a/code/grime_string_interning.odin b/code/grime_string_interning.odin index 07317f2..28a3fca 100644 --- a/code/grime_string_interning.odin +++ b/code/grime_string_interning.odin @@ -61,8 +61,7 @@ str_cache_init :: proc( /*allocator : Allocator*/ ) -> ( cache : StringCache ) { cache.slab, alloc_error = slab_init( & policy, allocator = persistent_allocator(), dbg_name = dbg_name ) verify(alloc_error == .None, "Failed to initialize the string cache" ) - // cache.table, alloc_error = zpl_hmap_init_reserve( StringCached, persistent_slab_allocator(), 4 * Kilobyte, dbg_name ) - cache.table, alloc_error = zpl_hmap_init_reserve( StringCached, persistent_slab_allocator(), 8, dbg_name ) + cache.table, alloc_error = zpl_hmap_init_reserve( StringCached, persistent_allocator(), 1 * Megabyte, dbg_name ) return } diff --git a/code/tick_update.odin b/code/tick_update.odin index 42271e3..447ec89 100644 --- a/code/tick_update.odin +++ b/code/tick_update.odin @@ -347,8 +347,8 @@ update :: proc( delta_time : f64 ) -> b32 // index := 0 widgets : Array(UI_Widget) - widgets, alloc_error = array_init_reserve( UI_Widget, frame_slab_allocator(), 8 ) - // widgets, alloc_error = array_init_reserve( UI_Widget, frame_slab_allocator(), 4 * Kilobyte ) + // widgets, alloc_error = array_init_reserve( UI_Widget, frame_slab_allocator(), 8 ) + widgets, alloc_error = array_init_reserve( UI_Widget, frame_slab_allocator(), 4 * Kilobyte ) widgets_ptr := & widgets label_id := 0