Skip to content

Commit

Permalink
feat(core): use all available cores by default (#2392)
Browse files Browse the repository at this point in the history
  • Loading branch information
puzpuzpuz committed Aug 3, 2022
1 parent a517bbd commit 2eef0bf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/main/java/io/questdb/PropServerConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,12 @@ public PropServerConfiguration(

int cpuAvailable = Runtime.getRuntime().availableProcessors();
int cpuUsed = 0;
int cpuSpare = 0;
if (cpuAvailable > 8) {
cpuSpare = 1;
} else if (cpuAvailable > 16) {
cpuSpare = 2;
}
final FilesFacade ff = cairoConfiguration.getFilesFacade();
try (Path path = new Path()) {
ff.mkdirs(path.of(this.root).slash$(), this.mkdirMode);
Expand Down Expand Up @@ -970,7 +976,7 @@ public PropServerConfiguration(
this.ilpAutoCreateNewColumns = getBoolean(properties, env, PropertyKey.LINE_AUTO_CREATE_NEW_COLUMNS, true);
this.ilpAutoCreateNewTables = getBoolean(properties, env, PropertyKey.LINE_AUTO_CREATE_NEW_TABLES, true);

this.sharedWorkerCount = getInt(properties, env, PropertyKey.SHARED_WORKER_COUNT, Math.max(1, cpuAvailable / 2 - 1 - cpuUsed));
this.sharedWorkerCount = getInt(properties, env, PropertyKey.SHARED_WORKER_COUNT, Math.max(2, cpuAvailable - cpuSpare - cpuUsed));
this.sharedWorkerAffinity = getAffinity(properties, env, PropertyKey.SHARED_WORKER_AFFINITY, sharedWorkerCount);
this.sharedWorkerHaltOnError = getBoolean(properties, env, PropertyKey.SHARED_WORKER_HALT_ON_ERROR, false);
this.sharedWorkerYieldThreshold = getLong(properties, env, PropertyKey.SHARED_WORKER_YIELD_THRESHOLD, 100);
Expand Down

0 comments on commit 2eef0bf

Please sign in to comment.