Process-Level Memory Authority#3
Open
jamon-bailey wants to merge 92 commits intoproc-threadsfrom
Open
Conversation
Introduce MemoryCore skeleton, implementation details remain incomplete and will be implemented in a follow-up.
Resources being studied for the implementation of a process-wide fixed-size memory block pool.
Added skeletons for process-wide MemoryPoolConfig and ProcessMemoryPool. Both are incomplete stubs; Update src/process/CMakeLists.txt to include the new source files
Prematurely adding necessary header dependency
Appended a comment block to dev_exe.cpp about potential debug-mode bad-address/sentinel values (several hex patterns and their decimal equivalents)
Annotate MemoryPoolConfig structure with CHEVRON_API to ensure proper symbol visibility from the shared library/object; Implementation remains incomplete
Added skeleton for strongly-typed DigitalSize template as a stub; Still incomplete
Moved digital size measurement facilities to 'include/chevron/common/units/digital' subdirectory; Implementation STILL INCOMPLETE
Add include/chevron/common/units/digital/unit_cast.hpp which introduces DigitalSizeCast, a constexpr template utility to convert between digital size unit types
Incomplete
Introduce a general units include header that centralizes unit-measure facilities; This front-facing header is still INCOMPLETE
Temporary 'size_t' references to be replaced with explicit unit types; Incomplete
Compile-time and runtime math utilities
Incomplete
Introduces an alignment and bit inspection header; Both headers incomplete
Adjustments to documentation comments
Introduce arithmetic and compound operators for DigitalSize; Moved class type traits above class definition
Replace raw size_t fields with unit-safe Bytes for block_size, chunk_size, and budget_ceiling in MemoryPoolConfig; Other fields and structure remain unchanged
Rolling example of application implementation with Chevron
Incomplete documentation
Added validation method stubs for process memory pool configuration; Incomplete implementation
Introduced memory description interface for types that are centered around describing a region in memory
Adjusted to inherit majority of public API from base memory description class
Introduced MemoryRegion class; inherits from memory description interface
Replace inconsistent comment "// TODO: INCOMPLETE DOC STRING!!!" with "TODO: INCOMPLETE DOCUMENTATION!!!"
The chunk descriptor type needs a default constructor to allocate instances in an array
Start of constructor and destructor for the process memory allocator; INCOMPLETE!!!
Removed invalid noexcept qualifier on method signature in header
- Catch polymorphic exception by reference rather than value - Adjusted comment banners
- Implementation in place - Still missing documentation comments
- Wrap possible failure point with try-catch statement - Misc. comment adjustments
Added new thread synchronization primitive to threading utilities. Tagged pointers require 16-byte atomics to account for a standard pointer and monotonically increasing swap counter INCOMPLETE DOCUMENTATION!!!
Introduced ScopeGuard which is a RAII guard that runs a provided lambda on scope exit for safe cleanup
Introduced general memory header that defines basic memory allocator types including FreeRegionNode and AtomicFreeListHead (an atomic TaggedPointer<void>) INCOMPLETE DOCUMENTATION!!!
- Included ScopeGuard and applied RAII to make allocation/error paths exception-safe - Removed manual try/catch blocks and simplified node construction; dismiss guards after successful publish. Improves safety and clarity without changing allocation semantics
Introduce ProcessMemoryPool declaration and core implementation. Header additions: new includes, ThreadLocalMemoryCache stub, FreeListHead alias, public ctor/dtor and inspection APIs, private members (free list head, bytes_acquired, blocks_per_chunk, config, allocator) and helper declarations. Source additions: constructor/destructor, block/chunk geometry computation, budget validation, allocator reinitialization, carve_and_link, push_batch/pop_batch implementing ABA-safe tagged-pointer CAS loops, and expand_memory with a budget gate, allocator acquisition and chunk integration (uses ScopeGuard/TaggedPointer). Many docs remain TODO and thread-local cache logic is left on-hold; this is a partial but functional core for lock-free block distribution.
Incomplete class declaration stub
Add alignas(16) to the TaggedPointer struct to guarantee 16-byte alignment. This ensures the type is properly aligned for double-width atomic operations
Introduce thread-local allocation/deallocation APIs and a CAS-based expansion gate to reduce contention and serialize OS memory growth. Changes: - Added ProcessMemoryPool::allocate() and deallocate() with a fast path using ThreadLocalMemoryCache and slow/refill paths that use pop_batch()/expand_memory(). - Extended ThreadLocalMemoryCache with free_blocks, adjusted semantics of cached_blocks, added has_memory_free(), and made drain_cache() non-const. - Implemented get_current_thread_cache() as a thread_local cache in the .cpp and updated its noexcept signature. - Added ExpandState (atomic ExpansionState) and expansion_state_ member; expand_memory() now uses CAS to ensure only one thread performs OS allocation, yielding other threads until expansion completes and restoring state with a scope guard. - Reordered and renamed some private helpers (carve_and_link, push_batch, pop_batch) and commented-out a platform lock-free static_assert. - Added #include <thread> in the implementation for yielding.
Introduce thread_mem_cache.cpp which adds the ThreadLocalMemoryCache methods for ProcessMemoryPool. - Implements destructor (drains cache), has_memory_free(), and drain_cache() that links the local free list into the shared pool via push_batch. - compute_growth_batch() and compute_shrink_batch() are added as INCOMPLETE placeholders
- Introduce TaggedPointer type to conditionally define FreeListHead to support MSVC's lack of a lock-free 128-bit std::atomic. - Add CHEVRON_MSVC code paths that use _InterlockedCompareExchange128 for loading and CAS on the free-list, while keeping std::atomic<TaggedPointer> for other platforms. - Include macro_defs.h and <intrin.h> (MSVC) and adjust push/pop logic accordingly. - Also clear block->next after allocation to avoid dangling links.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduction of process-wide memory management components