简体   繁体   English

AtomicReferenceFieldUpdater怀疑

[英]AtomicReferenceFieldUpdater doubt

I was creating a concurrnetHashtable that is suitable for me and little different from concurrentHashMap, and i am using AtomicReferenceFieldUpdater to make CASNext operation ( usually CAS is supported but by this we can perform CASNext also ), so am i going on right path ? 我正在创建一个适合我的concurrnetHashtable,它与并发HashMap几乎没有什么不同,并且我正在使用AtomicReferenceFieldUpdater进行CASNext操作(通常支持CAS,但是我们也可以执行CASNext),所以我走的路正确吗? Though usually i get good performance in this concurrentHashTable than locking hashtable, but sometimes things doesn't work out. 虽然通常在并发HashTable中我可以获得比锁定哈希表更好的性能,但是有时候事情还是无法解决。
So i came to following conclusion : 所以我得出以下结论:
if number of available processor are greater than number of bucket available in the hashtable then there are higher probability of getting lock contention, so in this case concurrentHashTable is going to work better than locking approach, and ofcourse if reading are much ( journals says 85-90% reading operation) , then it's good for use .. so please suggest me, am i going on the right path, and assuming things correctly ? 如果可用处理器的数量大于哈希表中可用的存储桶的数量,则获得锁争用的可能性更高,因此在这种情况下,并发哈希表将比锁定方法更好地工作,当然,如果读取量很大(期刊说85- 90%的阅读操作),那么它很好用..所以请建议我,我走的路正确无误,并且假设正确吗?
if you get time then see code on this page code In this hash table i am doing insertions if element is not present already... so tell me whether this is a correct lock-free approach ? 如果您有时间,请参阅此页上的代码代码在此哈希表中,如果元素尚不存在,我正在进行插入...所以告诉我这是否是正确的无锁方法?

Not a direct answer, but if you are looking to improve on CHM have a look at the one written by Dr. Cliff Click: here 这不是一个直接的答案,但是如果您想改善CHM,请查看Cliff博士撰写的文章。单击: 此处

Apart from that, it's hard to help without knowing what you are trying to solve... 除此之外,不知道您要解决的问题就很难提供帮助。

in a concurrent hash map there are 3 major operations to worry about: adding a element, removing an element and rehash 在并发哈希图中,需要担心3个主要操作:添加元素,删除元素并重新哈希

in removing and adding it's easy enough with CaS only 仅使用CaS即可轻松完成删除和添加

however a rehash will introduce races left and right which can result in data being dropped, elements not being visible for some ops, infinite loops and this is very hard to get right and using r/w locks on the whole table is much easier 但是,重新哈希处理将引入左右竞争,这可能会导致数据丢失,某些操作看不见元素, 无限循环 ,这很难做到,并且在整个表上使用r / w锁要容易得多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM