make sheet scope and cache use same bucket count
This commit is contained in:
parent
9733b1369e
commit
155226b60e
15
src/sheet.c
15
src/sheet.c
@ -17,7 +17,6 @@
|
||||
|
||||
#define TCTX_ARENA_RESERVE MEGABYTE(64)
|
||||
#define CACHE_BUCKETS_COUNT 1024
|
||||
#define SCOPE_BUCKETS_COUNT 1024
|
||||
|
||||
#define MAX_LOADER_THREADS 4
|
||||
|
||||
@ -372,13 +371,13 @@ struct sheet_scope *sheet_scope_begin(void)
|
||||
if (tctx->first_free_scope) {
|
||||
res = tctx->first_free_scope;
|
||||
tctx->first_free_scope = res->next_free;
|
||||
MEMZERO(res->reference_buckets, sizeof(*res->reference_buckets) * SCOPE_BUCKETS_COUNT);
|
||||
MEMZERO(res->reference_buckets, sizeof(*res->reference_buckets) * CACHE_BUCKETS_COUNT);
|
||||
*res = (struct sheet_scope) {
|
||||
.reference_buckets = res->reference_buckets
|
||||
};
|
||||
} else {
|
||||
res = arena_push_zero(&tctx->arena, struct sheet_scope);
|
||||
res->reference_buckets = arena_push_array_zero(&tctx->arena, struct sheet_scope_reference *, SCOPE_BUCKETS_COUNT);
|
||||
res->reference_buckets = arena_push_array_zero(&tctx->arena, struct sheet_scope_reference *, CACHE_BUCKETS_COUNT);
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -388,7 +387,7 @@ void sheet_scope_end(struct sheet_scope *scope)
|
||||
{
|
||||
struct sheet_tctx *tctx = thread_local_var_eval(&tl_sheet_tctx);
|
||||
sys_timestamp_t cur_timestamp = sys_timestamp();
|
||||
for (u64 i = 0; i < SCOPE_BUCKETS_COUNT; ++i) {
|
||||
for (u64 i = 0; i < CACHE_BUCKETS_COUNT; ++i) {
|
||||
struct sheet_scope_reference *ref = scope->reference_buckets[i];
|
||||
while (ref) {
|
||||
if (atomic_i32_dec_eval(&ref->cache_node->refcount) == 0) {
|
||||
@ -575,13 +574,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sheet_loader_thread_entry_point, arg)
|
||||
break;
|
||||
} else if (!G.first_loader_cmd) {
|
||||
/* Wait for work */
|
||||
#if 1
|
||||
sys_condition_variable_wait(&G.loaders_cv, &G.loaders_mutex);
|
||||
#else
|
||||
sys_mutex_unlock(&G.loaders_mutex);
|
||||
sys_sleep(0.5);
|
||||
sys_mutex_lock(&G.loaders_mutex);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@ -704,7 +697,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sheet_evictor_thread_entry_point, arg)
|
||||
sys_rw_mutex_unlock_shared(&G.cache.rw_mutex);
|
||||
|
||||
if (head_evict_node) {
|
||||
/* Scan for evictable nodes and remove from cache table */
|
||||
/* Remove evictable nodes from cache table */
|
||||
sys_rw_mutex_lock_exclusive(&G.cache.rw_mutex);
|
||||
{
|
||||
__profscope(eviction_cache_removal);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user