我的应用程序在缺省配置的情况下,5百多万条记录,Log File占用了532M的硬盘空间。仔细看了下文档,发现Berkeley DB日志文件占用的空间,有很大的弹性。Berkeley DB一直会以append的方式增加log文件,同时有clean log thread负责清理无用的log。为了更高的程序性能,Berkeley DB会根据参数的配置,允许已经失效的log存在于log file中,这样可以减少cleanLog thread和其他thread锁的竞争。而我希望提高log file的利用率,减少log占用的硬盘空间,并且能够容忍这样做带来的性能损失。因此修改了je.properties,定义je.cleaner.minUtilization为90(缺省为50),同时在关闭environment的时候,强制执行cleanLog:
boolean anyCleaned = false;
while (dbenv.cleanLog() > 0) {
anyCleaned = true;
}
if (anyCleaned) {
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
dbenv.checkpoint(force);
}
调整后,log file占用的空间下降为309M,效果非常明显。
je.properties
# maximum starting size of a JE log buffer
# 32M
je.log.bufferSize=33554432
# The number of JE log buffers
# minimum = 2
je.log.numBuffers=2
# The total memory taken by log buffers, in bytes. If 0, use
# 7% of je.maxMemory
# minimum = 6144
# 32M * 2
je.log.totalBufferBytes=67108864
# By default, JE sizes the cache as a percentage of the maximum
# memory available to the JVM. For example, if the JVM is
# started with -Xmx128M, the cache size will be
# (je.maxMemoryPercent * 128M) / 100
# Setting je.maxMemory to an non-zero value will override
# je.maxMemoryPercent
# minimum = 1
# maximum = 90
je.maxMemoryPercent=80
# If true (the default), use an LRU-only policy to select nodes for
# eviction. If false, select by Btree level first, and then by LRU.
je.evictor.lruOnly=false
# The number of nodes in one evictor scan
# minimum = 1
# maximum = 1000
je.evictor.nodesPerScan=100
# The cleaner will keep the total disk space utilization percentage
# above this value. The default is set to 50 percent.
# minimum = 0
# maximum = 90
je.cleaner.minUtilization=90
没有评论:
发表评论