Skip to content

Commit

Permalink
feat: update default conf (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
caojiajun committed Feb 11, 2025
1 parent 52a68ac commit 2fb4307
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class LocalStorageExecutors {

private static final Logger logger = LoggerFactory.getLogger(LocalStorageExecutors.class);

private static final int defaultThreads = Math.min(4, SysUtils.getCpuHalfNum());

private static volatile LocalStorageExecutors INSTANCE;

private final MpscSlotHashExecutor commandExecutor;
Expand All @@ -31,15 +33,11 @@ public class LocalStorageExecutors {

private LocalStorageExecutors() {
{
walAsync = ProxyDynamicConf.getBoolean("local.storage.wal.async.enable", false);
if (walAsync) {
walThreads = ProxyDynamicConf.getInt("local.storage.wal.write.threads", 4);
} else {
walThreads = 0;
}
walAsync = ProxyDynamicConf.getBoolean("local.storage.wal.async.enable", true);
walThreads = ProxyDynamicConf.getInt("local.storage.wal.write.threads", defaultThreads);
}
{
int threads = ProxyDynamicConf.getInt("local.storage.command.executor.threads", SysUtils.getCpuNum() * 3 / 10 - (walThreads / 2));
int threads = ProxyDynamicConf.getInt("local.storage.command.executor.threads", defaultThreads);
if (threads <= 0) {
threads = 4;
}
Expand All @@ -48,7 +46,7 @@ private LocalStorageExecutors() {
logger.info("local storage command executor init success, threads = {}, queueSize = {}", threads, queueSize);
}
{
int threads = ProxyDynamicConf.getInt("local.storage.flush.executor.threads", SysUtils.getCpuNum() * 2 / 10 - (walThreads / 2));
int threads = ProxyDynamicConf.getInt("local.storage.flush.executor.threads", defaultThreads);
if (threads <= 0) {
threads = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class SlotKeyReadWrite {
ProxyDynamicConf.registerCallback(SlotKeyReadWrite::updateConf);
}
private static void updateConf() {
int keyFlushSize = ProxyDynamicConf.getInt("local.storage.key.flush.size", 200);
int keyFlushSize = ProxyDynamicConf.getInt("local.storage.key.flush.size", 128);
if (SlotKeyReadWrite.keyFlushSize != keyFlushSize) {
SlotKeyReadWrite.keyFlushSize = keyFlushSize;
logger.info("local.storage.key.flush.size, update to {}", keyFlushSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class SlotStringReadWrite {
ProxyDynamicConf.registerCallback(SlotStringReadWrite::updateConf);
}
private static void updateConf() {
int stringValueFlushSize = ProxyDynamicConf.getInt("local.storage.string.value.flush.size", 200);
int stringValueFlushSize = ProxyDynamicConf.getInt("local.storage.string.value.flush.size", 128);
if (SlotStringReadWrite.stringValueFlushSize != stringValueFlushSize) {
SlotStringReadWrite.stringValueFlushSize = stringValueFlushSize;
logger.info("local.storage.string.value.flush.size, update to {}", stringValueFlushSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static CamelliaServerProperties parse(CamelliaRedisProxyProperties proper
try {
Resource resource = RedisResourceUtil.parseResourceByUrl(new Resource(properties.getTranspond().getLocal().getResource()));
if (resource instanceof RedisLocalStorageResource) {
serverProperties.setWorkThread(SysUtils.getCpuHalfNum());
serverProperties.setWorkThread(Math.min(4, SysUtils.getCpuHalfNum()));
} else {
serverProperties.setWorkThread(SysUtils.getCpuNum());
}
Expand Down

0 comments on commit 2fb4307

Please sign in to comment.