unloggedio / unlogged-sdk

Unlogged SDK for recording JAVA code execution
https://unlogged.io
Apache License 2.0
181 stars 18 forks source link

Optimize Thread Safety and Performance in Logging System Through Concurrency Enhancements and Count Management Refactoring #19

Closed kartikeytewari-ul closed 11 months ago

kartikeytewari-ul commented 12 months ago

Key changes include:

  1. Replacing Synchronization with Concurrent Collections: The HashMap instances in PerThreadBinaryFileAggregatedLogger are replaced with ConcurrentHashMap. This change implies an effort to improve the thread safety of the system without relying on explicit synchronization, which can be a performance bottleneck.

  2. Simplifying getThreadEventCount Method: The getThreadEventCount method is simplified across several classes. It previously returned an AtomicInteger but now directly returns an int. This change suggests a shift in how thread event counts are managed, potentially optimizing the performance by reducing the overhead of atomic operations.

  3. Refactoring Count Management: The management of thread event counts appears to be streamlined. Instead of using AtomicInteger, simple integers are now used, and a new method, getThreadEventCountinc, is introduced to increment these counts. This approach, combined with the use of concurrent collections, suggests an effort to balance thread safety with efficiency.

  4. Removal of Redundant Code: Some redundant or unused code is removed, such as the doneFinalize variable in RawFileCollector, indicating a focus on code cleanliness and efficiency.

kartikeytewari-ul commented 12 months ago

Add a performance analysis