什么是Java的-XX:+ UseMembar参数 [英] What is Java's -XX:+UseMembar parameter

查看:191
本文介绍了什么是Java的-XX:+ UseMembar参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在各种地方(论坛等)都看到此参数,常见的回答是它有助于高度并发的服务器.不过,我找不到sun提供的官方文档来说明其功能.另外,它是在Java 6中添加的还是在Java 5中存在的?

I see this parameter in all kinds of places (forums, etc.) and the common answer it help highly concurrent servers. Still, I cannot find an official documentation from sun explaining what it does. Also, was it added in Java 6 or did it exist in Java 5?

(顺便说一句,此页面, a>)

(BTW, a good place for many hotspot VM parameters is this page)

更新:Java 5不使用此参数启动.

Update: Java 5 does not boot with this parameter.

推荐答案

为了优化性能,JVM在多个处理器之间进行同步时,在代码中使用伪内存屏障"作为隔离指令.可以恢复为"true"的内存屏障指令,但是这可能会对性能产生明显的(和不利的)影响.

In order to optimise performance, the JVM uses a "pseudo memory barrier" in code to act as a fencing instruction when synchronizing across multiple processors. It is possible to revert back to a "true" memory barrier instruction, but this can have a noticeable (and bad) effect upon performance.

使用-XX:+UseMembar会使VM恢复为真实的内存屏障指令.此参数原本打算作为新的伪屏障逻辑的验证机制暂时存在,但事实证明,新的伪内存屏障代码引入了一些同步问题.我相信这些问题现已解决,但是直到解决这些问题之前,解决这些问题的可接受方法是使用恢复的标志.

The use of -XX:+UseMembar causes the VM to revert back to true memory barrier instructions. This parameter was originally intended to exist temporarily as a verification mechanism of the new pseudo-barrier logic, but it turned out that the new pseudo-memory barrier code introduced some synchronization issues. I believe these are now fixed, but until they were, the acceptable way to get around these issues was to use the reinstated flag.

该错误是在1.5版中引入的,我相信该标记存在于1.5版和1.6版中.

The bug was introduced in 1.5, and I believe the flag exists in 1.5 and 1.6.

我已经从各种邮件列表和JVM错误中对它进行了谷歌化:

I've google-fu'ed this from a variety of mailing lists and JVM bugs:

  • http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6546278
  • The obligatory Wikipedia link to memory barriers (fencing instructions)
  • A classic post from Raymond Chen
  • SO question on fencing

这篇关于什么是Java的-XX:+ UseMembar参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆