提交 9a663852 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

MVStore: add feature to set the cache concurrency

上级 f7851cc3
...@@ -91,6 +91,8 @@ Change Log ...@@ -91,6 +91,8 @@ Change Log
when using larger databases and many threads. when using larger databases and many threads.
To re-enable, use the file name prefix "cache:". To re-enable, use the file name prefix "cache:".
</li> </li>
<li>MVStore: add feature to set the cache concurrency.
</li>
<li>LIRS cache: improved hit rate because now added entries get hot if they <li>LIRS cache: improved hit rate because now added entries get hot if they
were in the non-resident part of the cache before. were in the non-resident part of the cache before.
</li> </li>
......
...@@ -326,6 +326,10 @@ public class MVStore { ...@@ -326,6 +326,10 @@ public class MVStore {
if (mb > 0) { if (mb > 0) {
CacheLongKeyLIRS.Config cc = new CacheLongKeyLIRS.Config(); CacheLongKeyLIRS.Config cc = new CacheLongKeyLIRS.Config();
cc.maxMemory = mb * 1024L * 1024L; cc.maxMemory = mb * 1024L * 1024L;
o = config.get("cacheConcurrency");
if (o != null) {
cc.segmentCount = (Integer) o;
}
cache = new CacheLongKeyLIRS<Page>(cc); cache = new CacheLongKeyLIRS<Page>(cc);
cc.maxMemory /= 4; cc.maxMemory /= 4;
cacheChunkRef = new CacheLongKeyLIRS<PageChildren>(cc); cacheChunkRef = new CacheLongKeyLIRS<PageChildren>(cc);
...@@ -2826,6 +2830,16 @@ public class MVStore { ...@@ -2826,6 +2830,16 @@ public class MVStore {
return set("cacheSize", mb); return set("cacheSize", mb);
} }
/**
* Set the read cache concurrency. The default is 16, meaning 16 segments are used.
*
* @param concurrency the cache concurrency
* @return this
*/
public Builder cacheConcurrency(int concurrency) {
return set("cacheConcurrency", concurrency);
}
/** /**
* Compress data before writing using the LZF algorithm. This will save * Compress data before writing using the LZF algorithm. This will save
* about 50% of the disk space, but will slow down read and write * about 50% of the disk space, but will slow down read and write
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论