Skip to content

Improve concurrency and caching in server utilities#416

Open
Nu11ified wants to merge 1 commit intoMultiPaper:mainfrom
Nu11ified:main
Open

Improve concurrency and caching in server utilities#416
Nu11ified wants to merge 1 commit intoMultiPaper:mainfrom
Nu11ified:main

Conversation

@Nu11ified
Copy link
Copy Markdown

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-safe ChunkLock class with timeout functionality. Atomic counters track active locks and timeouts.
  • FileLocker: Replaced HashMap with ConcurrentHashMap for thread safety, added locks for synchronization, and implemented an LRU cache for frequently accessed files. [1] [2]
  • RegionFileCache: Introduced ReadWriteLock for concurrent access to the cache and added a ConcurrentHashMap for canonical path caching. Optimized cache eviction logic using locks. [1] [2]

Configurability Enhancements:

  • ChunkLock and EntitiesLock: 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 the times array final for immutability.
  • ForceReadChunkHandler: Simplified nested callbacks by combining them into a single lambda expression.

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.
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