我们希望在一些高性能代码中最小化(如果不是消除)对象分配。在以前版本的编年史地图(版本2.x)中,这在很大程度上是可能的。在最新版本的编年史地图(3.17.1)中,我们在使用ExternalMapQueryContext时看到了显着的分配。我们在这里遵循教程:https://github.com/OpenHFT/Chronicle-Map/blob/master/docs/CM_Tutorial.adoc
这是意料之中的吗?我们使用的是正确的方法吗?
VOInterface voi = VO.get();
try (ExternalMapQueryContext < CharSequence, voi, ? > ctx = map.queryContext(key)) {
if (ctx.readLock().tryLock()) {
MapEntry < CharSequence, voi > entry = ctx.entry();
if (entry != null) {
// Entry is present, return
entry.value().getUsing(voi);
accessor.accessData(voi);
// Key is absent
// Need to unlock, to lock to update lock later. Direct upgrade is forbidden.
ctx.readLock().unlock();
return true;
} else {
accessor.notFound();
// Key is absent
// Need to unlock, to lock to update lock later. Direct upgrade is forbidden.
ctx.readLock().unlock();
return false;
}
}
ctx.updateLock().lock();
MapEntry < CharSequence, voi > entry = ctx.entry();
if (entry != null) {
entry.value().getUsing(voi);
accessor.accessData(voi);
return true;
} else {
accessor.notFound();
return false;
}
}我们也有可以分享的分配堆栈的屏幕截图。
发布于 2019-05-09 02:32:33
我们有一个每秒执行数百万次操作的测试net.openhft.chronicle.map.ChronicleMapTest#testAcquireLockedPerf。您可以使用以下命令运行此命令
-Xmx64m -verbose:gc对于这种情况,尽管有64MB的堆,但在预热之后,对于数亿次操作,测试不会触发一个gc。
要弄清楚为什么你的特定案例会产生大量的垃圾,需要更多的调查。
https://stackoverflow.com/questions/56008176
复制相似问题