[
https://issues.jboss.org/browse/JGRP-1396?page=com.atlassian.jira.plugin....
]
Bela Ban commented on JGRP-1396:
--------------------------------
OK, so I came up with this lockless RingBuffer, but then I created a copy, this time using
a lock to synchronize access to add(), removeMany() etc, and the synchronized version was
faster than the lockless version !
I guess, if I compare the 2:
lockless:
---------
public void add() {
// read volatile HD
// ...
// write volatile HR
// write volatile HD
}
synchronized:
-------------
public void add() {
synchronized {
// read HD (non-volatile)
// ...
// write HR
// write HD
}
}
The lockless version has lots of reads and writes to the same volatile fields (memory
barriers), so most of the reads will not find their value in the cache and thus have to
read the value from memory (or a 2nd level cache). Most writes will flush the cache, so
this is slow.
Plus, if we have false sharing (e.g. HD and LOW on the same cache line), then this gets
compounded...
OTOH, the synchronized version does a read before the synchronization and a flush when
exiting it. The cost of acquiring a lock is apparently smaller than the many memory
barriers that get executed !
NAKACK2: merge NakReceiverWindow and Retransmitter
--------------------------------------------------
Key: JGRP-1396
URL:
https://issues.jboss.org/browse/JGRP-1396
Project: JGroups
Issue Type: Enhancement
Reporter: Bela Ban
Assignee: Bela Ban
Fix For: 3.1
Both NakReceiverWindow and Retransmitter use their own data structures to keep a list of
messages received (NRW) and seqnos to be retransmitted (Retrasmitter). This is redundant
and costly memory-wise.
I suggest let's merge the 2 classes, or at least let them share the data structure
which keeps track of received messages.
Suggestion II: create a ring buffer with a (changeable) capacity that keeps track of
received messages and messages to be retransmitted.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira