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.
This commit is contained in:
Edward R. Gonzalez 2024-05-07 01:34:43 -04:00
parent 3336ab2e1c
commit e282397bf0
6 changed files with 8 additions and 9 deletions

View File

@ -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

View File

@ -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 )

View File

@ -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 {

View File

@ -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

View File

@ -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
}

View File

@ -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