-
-
Notifications
You must be signed in to change notification settings - Fork 3
Use simple std::mutex in the cache class #19
Copy link
Copy link
Open
Description
The cache hash table currently uses shared locks (std::shared_mutex) to enable concurrent reads and exclusive writes. However, internal tests conducted on standard workstations indicate that the overhead of std::shared_mutex may outweigh its benefits, particularly when compared to std::mutex. This appears to be due to the short critical section in the find member function, which might not justify the complexity of read-write locks.
Observations
- On systems with a limited number of CPUs or hardware threads, the contention for
std::shared_mutexmay introduce significant overhead, reducing the performance advantage of concurrent reads. - On systems with a greater number of CPUs or hardware threads, the benefits of
std::shared_mutexmay become more apparent, as contention is distributed across more resources.
Cross-Platform Considerations
- Differences between operating systems, particularly Linux and Windows, may lead to varying performance characteristics for
std::shared_mutexdue to differences in underlying implementations. - Further testing is required to evaluate these differences and ensure consistent performance across platforms.
Recommendations
Benchmarking
- Perform detailed benchmarks comparing
std::shared_mutexandstd::mutexon systems with varying CPU and thread counts. - Evaluate performance differences across Linux and Windows platforms.
Simplification
Consider replacing std::shared_mutex with std::mutex if benchmarks show consistent performance improvements and the benefits of concurrent reads are negligible.
References:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels