Skip to content

optimize: Cache Clib4Resource pointer to eliminate repeated OpenResource() calls in malloc - #439

Merged
afxgroup merged 1 commit into
developmentfrom
optimize-malloc-resource-cache
Jun 28, 2026
Merged

optimize: Cache Clib4Resource pointer to eliminate repeated OpenResource() calls in malloc#439
afxgroup merged 1 commit into
developmentfrom
optimize-malloc-resource-cache

Conversation

@afxgroup

Copy link
Copy Markdown
Collaborator
  • Add __clib4_resource field to struct _clib4 for caching the global resource pointer
  • Initialize cache once in stdlib_memory_init instead of calling OpenResource() on every allocation
  • Update __get_wmem_allocator, __memory_lock, and __memory_unlock to use cached pointer
  • Eliminates 3 OpenResource() calls per malloc/free (hot path optimization)
  • Maintains global allocator semantics and thread-safety through shared resource semaphore

…rce() calls in malloc

- Add __clib4_resource field to struct _clib4 for caching the global resource pointer
- Initialize cache once in stdlib_memory_init instead of calling OpenResource() on every allocation
- Update __get_wmem_allocator, __memory_lock, and __memory_unlock to use cached pointer
- Eliminates 3 OpenResource() calls per malloc/free (hot path optimization)
- Maintains global allocator semantics and thread-safety through shared resource semaphore
@afxgroup
afxgroup merged commit db79871 into development Jun 28, 2026
3 checks passed
@afxgroup
afxgroup deleted the optimize-malloc-resource-cache branch June 28, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant