1. 1、本文档共20页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Disruptor

Memory Barrier 内存障Modern processors perform out-of-order execution of instructions and out-of-order loads and stores of data between memory and execution units for performance reasons. The processors need only guarantee that program logic produces the same results regardless of execution order.它是一个CPU指令:a)Memory barriers are used by processors to indicate sections of code where the ordering of memory updates is important. b)They are the means by which hardware ordering and visibility of change is achieved between threads. Memory Barrier 内存障插入一个内存障会告诉CPU和编译器在那个命令之前执行的需要呆在那个命令之前,在那个命令之后执行的需要呆在那之后。内存障做的另一件事是强制各种CPU缓存的更新。比如,一个写障会把在这个障之前写到缓存的数据全刷新,于是其他任何线程去读那个数据都会拿到最新的版本,不管它是由哪个内核或socket执行的。A read memory barrier orders load instructions on the CPU that executes it by marking a point in the invalidate queue for changes coming into its cache. This gives it a consistent view of the world for write operations ordered before the read barrier.A full memory barrier orders both loads and stores but only on the CPU that executes it.A write barrier orders store instructions on the CPU that executes it by marking a point in the store buffer, thus flushing writes out via its cache. This barrier gives an ordered view to the world of what store operations happen before the write barrier.Memory Barrier 内存障在java中,这里神奇的咒语是单词“volatile”。如果你的字段是volatile的,Java内存模型会在你对它写入之后插入一个写障指令,并且在你对它读取之前插入一个读障指令。这意味着如果你对一个volatile字段写入: a)任何在你对这个字段写入之后访问它的线程都会得到更新后的值。  b)任何你在对这个字段写入之前做的事都被确保发生过了,而任何更新 过的数据值都会变得可见,因为内存障把所有早先对缓存的写入都刷新了。Cache Line Padding 高速缓存行 补齐内存缓存系统中基本单元是高速缓存行(Cache lines)。CPU会把数据从内存加载到高速缓存中 ,这样可以获得更好的性能,高速缓存默认大小是64 Byte为一个区域,一个区域在一个时间点只允许一个核心操作,也就是说不能有多个核心同时操作一个缓存区域。False Sharing 伪共享如果两个独立的线程同时对那两个值写入会怎样 Disruptor Handle Mode(1)UniCast a series of items between 1 publisher and 1 EventProcessor:一个publisher 一个eventprocessorP1? - Publisher 1RB? - RingBufferSB? - SequenceBarrierEP1 -EventProcessor 1 Handle Model(1) RingBufferValueEvent?ringBuffer?=???new?RingBufferValueEvent(Value

文档评论(0)

mv2323 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档