Furrballs: A C++17 Offset-Based Caching solution
Basic Archiving and caching solution, It'll feature LZ4 on-the-fly compression, LRU eviction plan and Offset-based Caching. It's primary target is Game Engines, thus Furrballs aims to have as low latency as possible.
The plan is to have a basic solution with minimal dependencies (Simply because Cachelib had to many dependencies)
Requirements:
-CMake
-C++17
-LZ4
-RocksDB
-64-bit System
AMP employs a counter that increments on eviction when a cache entry is accessed. If this counter exceeds a specified threshold, the cache expands to accommodate more values. Each expansion also triggers an increment of a secondary counter. If this secondary counter reaches its threshold, the number of pages allocated in the expansion increases to prevent temporary fragmentation.
The memory pool introduces an indirection layer for pointers returned by the library, using virtual pointers that remain valid even if the underlying data is moved. This enables defragmentation without invalidating pointers, allowing the use of the upper bits for metadata.
Note: The defragmentation operation should block all threads. Consider researching non-blocking memory management solutions such as Hoard or TBB, or implementing incremental memory expansion using a separate thread.
Important: This approach assumes that very large memory usage or large pointers are not considered. If such large memory usage occurs, the system will break and may require an alternative approach that avoids using virtual pointers. This issue is relevant only for servers with very large memory available, which are not the target for this library.
Additionally, this solution is designed exclusively for 64-bit systems, as enforced by the build system.
Use 'const' on member functions and arguments when ever it's possible.
All functions should be noexcept unless they explicitly throw as an indication to user.
Everything should be designed with Multi-threading in mind.
When possible use atomic types/operations.
Allow for modularity and integration with and into other projects. (ex: allow for the use of a threadpool or a job system provided externally for burst)
Only paging system is allowed to allocated memory, any allocation goes through it (or MemoryManager class) if independent buffer is needed
Exceptions are only for unrecoverable errors or rare uses otherwise continue gracefully and inform user.
In case of Exceptions:
This is to guarantee that all constructed objects are initialized correctly without requiring additional checks after creation or else 'nullptr' is returned.
This is to guarantee that Cleanup is always reliable, stable and callable without additional precaution.
In any other case Prioritize performance and low latency over all.
Mark code as critical to indicate that the guidelines are overriden. Do not abuse this.
Priorities are Unix(POSIX) and Windows. macOS is not a priority.
Because of limited use (none to be exact) or compatibility considerations, macOS-related issues will not be the primary focus. Specifically, the author will not engage with macOS-related issues, conform to macOS guidelines, or implement macOS-specific code. (This decision is based on a personal preference to avoid Apple products, though POSIX compliance allows for indirect support.)