Improve concurrency and caching in server utilities#416
Open
Nu11ified wants to merge 1 commit intoMultiPaper:mainfrom
Open
Improve concurrency and caching in server utilities#416Nu11ified wants to merge 1 commit intoMultiPaper:mainfrom
Nu11ified wants to merge 1 commit intoMultiPaper:mainfrom
Conversation
Refactored ChunkLockManager, FileLocker, CallDataStorageHandler, EntitiesLock, ChunkLock, and RegionFileCache to use thread-safe data structures, configurable parameters, and improved concurrency controls. Added LRU caches, atomic counters, scheduled cleanup tasks, and read/write locks for better performance and reliability under concurrent access. Also made lock and cache sizes configurable via system properties.
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.
This pull request introduces several enhancements to improve concurrency, memory management, and configurability. Key changes include the addition of thread-safe data structures, scheduled executors for periodic tasks, and configurable parameters for locks and caches. The updates also simplify and optimize existing code for better performance and scalability.
Concurrency Improvements:
ChunkLockManager: Added a scheduled executor for periodic cleanup of expired locks and implemented a thread-safeChunkLockclass with timeout functionality. Atomic counters track active locks and timeouts.FileLocker: ReplacedHashMapwithConcurrentHashMapfor thread safety, added locks for synchronization, and implemented an LRU cache for frequently accessed files. [1] [2]RegionFileCache: IntroducedReadWriteLockfor concurrent access to the cache and added aConcurrentHashMapfor canonical path caching. Optimized cache eviction logic using locks. [1] [2]Configurability Enhancements:
ChunkLockandEntitiesLock: Made the number of locks configurable via system properties and ensured the lock count is a power of two for efficient modulo operations. [1] [2]CallDataStorageHandler: Added configurable parameters for save delay and cache size, along with a scheduled executor for automatic save operations.Code Simplifications:
CircularTimer: Made thetimesarrayfinalfor immutability.ForceReadChunkHandler: Simplified nested callbacks by combining them into a single lambda expression.