这些在JMH中使用的奇怪布尔值是什么? [英] What are these weird booleans used for in JMH?

查看:121
本文介绍了这些在JMH中使用的奇怪布尔值是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了

I wrote a JMH test about the cost of new instruction, and checked the class files it generates. Except the usual classes, there're tons of derived classes in generated folder:

这真的让我感到震惊,因为只有很少的注释会导致如此多的类通过继承绑定在一起.我很好奇这些类中的内容,因此我使用了称为procyon的反编译工具(顺便说一句,我从KotlinConf 2019的一次演讲中学到了该工具)来反编译这些生成的类,其中大多数与控件相关,例如测量时间(明确指定的内容不能内联)并收集指标.但是在那些班级里有很多奇怪的布尔值:

This really shocked me, for just few annotations will lead to so many class bounded together through inheritance. I am curious about what things are in those class, so I use a decompile tool (BTW I learned this tool from one talk on KotlinConf 2019) called procyon to decompile these generated class, most of them are control related, like measure time (they are explicitly specified can't be inlined) and collect metrics. But there're tons of weird boolean in those class:

在其他生成的类文件中也有很多布尔值.我用谷歌搜索,似乎它们是从

there're many booleans in other generted class files as well. I googled this, and seems they're somewhat derived from JMH sourse code. So I want to ask what is these booleans used for? I will assume they are closely related to the working principle underlying the JMH... seems no comments about the booleans in JMH source code.

还有,从一开始就对改善JMH测试有什么建议吗?我知道测试这种东西可能非常棘手且容易受到攻击,因此我不知道它们是否准确或足够可靠.

Also, any suggestions about improving the JMH test I mentioned from the very beginning...? I know testing such thing can be very tricky and vulnerable, so I don't know if they are accurate, or reliable enough.

非常感谢.

推荐答案

只是猜测.

如您所见,布尔值是私有的,并且在源文件中未使用.它们可能通过反射在某处使用,但我敢打赌它们不是.因此,剩下的唯一事情就是确保markerBegin和另一个字段属于不同的缓存,以防止错误共享.

As you can see, the booleans are private and unused in the source file. They might be used somewhere via reflection, but I'd bet they aren't. So the only thing left is ensuring that markerBegin and the other field belong to a different cache in order to prevent false sharing.

这篇关于这些在JMH中使用的奇怪布尔值是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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