Показаны сообщения с ярлыком concurrency. Показать все сообщения
Показаны сообщения с ярлыком concurrency. Показать все сообщения

четверг, 29 марта 2012 г.

ordered high throughput message monitor

Consider we have some high-throughput message listener, say processing more than 1000 messages per sec and there is a task to add some checks on each message like latency or correct ordering checks.

The task is quite common in remote messaging systems with failover functionality: e.g. you can miss a few messages when your messaging system is failovered or get stale ones due to some network issues or bugs in your messaging system itself.

Latency checks are OK - just compare operation between 2 timestamps eventually.

The problem is with ordering checks as surely we'll have some race-conditions here but using locks/synchronization will most likely kill performance and scalability.

So we need some kind of non-blocking algorithm - sure CAS atomics will help us.

Let's specify the requirements, we need:
-track for missed messages (when get forward ones)
-ignore the stale messages (when get old)
No more words, let's just code it:

пятница, 8 июля 2011 г.

jvm reordering tests

I was playing with java memory visibility and wrote a few tests for reordering. My examples break java safe publication idiom, so the jvm is free to reorder constructor instructions and object link initialization. But no reordering effect I've got so far, seems modern architectures don't allow it anymore