WIP: [#2187] MessageAudit modernization and performance optimization#2252
WIP: [#2187] MessageAudit modernization and performance optimization#2252mattrpav wants to merge 4 commits into
Conversation
- Lock-free CAS-based ring buffer replacement for BitArrayBin using AtomicLongArray vs synchronization. - Includes unit tests for correctness, equivalence with BitArrayBin, and concurrent stress tests
Fully lock-free message audit using ConcurrentHashMap for producer lookup using computeIfAbsent and AtomicBitArrayBin for CAS-based per-producer bit operations. No synchronized blocks for audit hot path.
Message audit using Caffeine cache with size-based TinyLfu eviction paired with lock-free AtomicBitArrayBin for per-producer bit operations. Provides bounded producer tracking with automatic eviction, compared to ConcurrentMessageAudit ConcurrentHashMap.
9241581 to
ab6fee1
Compare
There was a problem hiding this comment.
CaffeineMessageAudit is not going to work without some tweaks as it isn't entirely thread safe. The map updates (adding/removing) from the cache would be ok but it doesn't protect another thread from removing or update after you get an object from the cache.
For example in your rollback method:
var bab = cache.getIfPresent(pid.toString());
// At this point another thread could remove/update the entry in the cache
if (bab != null) {
bab.setBit(id.getProducerSequenceId(), false);
}|
Also, from first glance the The main issue here is verifying it's actually correct and truly thread safe and won't introduce weird bugs |
Uh oh!
There was an error while loading. Please reload this page.