add the ability to set the priority of the render process as commandline argument
This commit is contained in:
committed by
Laurent Clouet
parent
2f00d7816d
commit
d8aa315699
@@ -47,6 +47,7 @@ public class Configuration {
|
|||||||
private String proxy;
|
private String proxy;
|
||||||
private int maxUploadingJob;
|
private int maxUploadingJob;
|
||||||
private int nbCores;
|
private int nbCores;
|
||||||
|
private int priority;
|
||||||
private ComputeType computeMethod;
|
private ComputeType computeMethod;
|
||||||
private GPUDevice GPUDevice;
|
private GPUDevice GPUDevice;
|
||||||
private boolean printLog;
|
private boolean printLog;
|
||||||
@@ -63,6 +64,7 @@ public class Configuration {
|
|||||||
this.static_exeDirName = "exe";
|
this.static_exeDirName = "exe";
|
||||||
this.maxUploadingJob = 1;
|
this.maxUploadingJob = 1;
|
||||||
this.nbCores = -1; // ie not set
|
this.nbCores = -1; // ie not set
|
||||||
|
this.priority = 19;
|
||||||
this.computeMethod = null;
|
this.computeMethod = null;
|
||||||
this.GPUDevice = null;
|
this.GPUDevice = null;
|
||||||
this.userSpecifiedACacheDir = false;
|
this.userSpecifiedACacheDir = false;
|
||||||
@@ -125,6 +127,20 @@ public class Configuration {
|
|||||||
return this.nbCores;
|
return this.nbCores;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setUsePriority(int priority) {
|
||||||
|
if (priority > 19)
|
||||||
|
priority = 19;
|
||||||
|
if (priority < -19)
|
||||||
|
priority = -19;
|
||||||
|
|
||||||
|
this.priority = priority;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPriority() {
|
||||||
|
return this.priority;
|
||||||
|
}
|
||||||
|
|
||||||
public void setPrintLog(boolean val) {
|
public void setPrintLog(boolean val) {
|
||||||
this.printLog = val;
|
this.printLog = val;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ public class Job {
|
|||||||
|
|
||||||
new_env.put("BLENDER_USER_CONFIG", config.workingDirectory.getAbsolutePath().replace("\\", "\\\\"));
|
new_env.put("BLENDER_USER_CONFIG", config.workingDirectory.getAbsolutePath().replace("\\", "\\\\"));
|
||||||
new_env.put("CORES", Integer.toString(config.getNbCores()));
|
new_env.put("CORES", Integer.toString(config.getNbCores()));
|
||||||
|
new_env.put("PRIORITY", Integer.toString(config.getPriority()));
|
||||||
|
|
||||||
for (String arg : command1) {
|
for (String arg : command1) {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
|
|||||||
@@ -161,7 +161,12 @@ public class FreeBSD extends OS {
|
|||||||
}
|
}
|
||||||
if (this.hasNiceBinary.booleanValue()) {
|
if (this.hasNiceBinary.booleanValue()) {
|
||||||
// launch the process in lowest priority
|
// launch the process in lowest priority
|
||||||
actual_command.add(0, "19");
|
if (env_overight != null) {
|
||||||
|
actual_command.add(0, env_overight.get("PRIORITY"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
actual_command.add(0, "19");
|
||||||
|
}
|
||||||
actual_command.add(0, "-n");
|
actual_command.add(0, "-n");
|
||||||
actual_command.add(0, NICE_BINARY_PATH);
|
actual_command.add(0, NICE_BINARY_PATH);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,12 @@ public class Linux extends OS {
|
|||||||
}
|
}
|
||||||
if (this.hasNiceBinary.booleanValue()) {
|
if (this.hasNiceBinary.booleanValue()) {
|
||||||
// launch the process in lowest priority
|
// launch the process in lowest priority
|
||||||
actual_command.add(0, "19");
|
if (env_overight != null) {
|
||||||
|
actual_command.add(0, env_overight.get("PRIORITY"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
actual_command.add(0, "19");
|
||||||
|
}
|
||||||
actual_command.add(0, "-n");
|
actual_command.add(0, "-n");
|
||||||
actual_command.add(0, NICE_BINARY_PATH);
|
actual_command.add(0, NICE_BINARY_PATH);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,12 @@ public class Mac extends OS {
|
|||||||
}
|
}
|
||||||
if (this.hasNiceBinary.booleanValue()) {
|
if (this.hasNiceBinary.booleanValue()) {
|
||||||
// launch the process in lowest priority
|
// launch the process in lowest priority
|
||||||
actual_command.add(0, "19");
|
if (env != null) {
|
||||||
|
actual_command.add(0, env.get("PRIORITY"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
actual_command.add(0, "19");
|
||||||
|
}
|
||||||
actual_command.add(0, "-n");
|
actual_command.add(0, "-n");
|
||||||
actual_command.add(0, NICE_BINARY_PATH);
|
actual_command.add(0, NICE_BINARY_PATH);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,13 @@ public class Windows extends OS {
|
|||||||
}
|
}
|
||||||
Process p = builder.start();
|
Process p = builder.start();
|
||||||
WinProcess wproc = new WinProcess(p);
|
WinProcess wproc = new WinProcess(p);
|
||||||
wproc.setPriority(WinProcess.PRIORITY_BELOW_NORMAL);
|
if (env != null) {
|
||||||
|
String priority = env.get("PRIORITY");
|
||||||
|
wproc.setPriority(getPriorityClass(Integer.parseInt(priority)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wproc.setPriority(WinProcess.PRIORITY_BELOW_NORMAL);
|
||||||
|
}
|
||||||
if (env != null) {
|
if (env != null) {
|
||||||
String cores = env.get("CORES");
|
String cores = env.get("CORES");
|
||||||
wproc.setAffinity(Integer.parseInt(cores));
|
wproc.setAffinity(Integer.parseInt(cores));
|
||||||
@@ -140,6 +146,65 @@ public class Windows extends OS {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getPriorityClass(int priority) {
|
||||||
|
int process_class = WinProcess.PRIORITY_IDLE;
|
||||||
|
switch (priority) {
|
||||||
|
case 19:
|
||||||
|
case 18:
|
||||||
|
case 17:
|
||||||
|
case 16:
|
||||||
|
case 15:
|
||||||
|
process_class = WinProcess.PRIORITY_IDLE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 14:
|
||||||
|
case 13:
|
||||||
|
case 12:
|
||||||
|
case 11:
|
||||||
|
case 10:
|
||||||
|
case 9:
|
||||||
|
case 8:
|
||||||
|
case 7:
|
||||||
|
case 6:
|
||||||
|
case 5:
|
||||||
|
process_class = WinProcess.PRIORITY_BELOW_NORMAL;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
case 3:
|
||||||
|
case 2:
|
||||||
|
case 1:
|
||||||
|
case 0:
|
||||||
|
case -1:
|
||||||
|
case -2:
|
||||||
|
case -3:
|
||||||
|
process_class = WinProcess.PRIORITY_NORMAL;
|
||||||
|
break;
|
||||||
|
case -4:
|
||||||
|
case -5:
|
||||||
|
case -6:
|
||||||
|
case -7:
|
||||||
|
case -8:
|
||||||
|
case -9:
|
||||||
|
process_class = WinProcess.PRIORITY_ABOVE_NORMAL;
|
||||||
|
break;
|
||||||
|
case -10:
|
||||||
|
case -11:
|
||||||
|
case -12:
|
||||||
|
case -13:
|
||||||
|
case -14:
|
||||||
|
process_class = WinProcess.PRIORITY_HIGH;
|
||||||
|
break;
|
||||||
|
case -15:
|
||||||
|
case -16:
|
||||||
|
case -17:
|
||||||
|
case -18:
|
||||||
|
case -19:
|
||||||
|
process_class = WinProcess.PRIORITY_REALTIME;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return process_class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean kill(Process process) {
|
public boolean kill(Process process) {
|
||||||
if (process != null) {
|
if (process != null) {
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ public class Worker {
|
|||||||
@Option(name = "--no-systray", usage = "Don't use systray", required = false)
|
@Option(name = "--no-systray", usage = "Don't use systray", required = false)
|
||||||
private boolean no_systray = false;
|
private boolean no_systray = false;
|
||||||
|
|
||||||
|
@Option(name = "-priority", usage = "Set render process priority (19 lowest to -19 highest)", required = false)
|
||||||
|
private int priority = 19;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new Worker().doMain(args);
|
new Worker().doMain(args);
|
||||||
}
|
}
|
||||||
@@ -112,6 +115,7 @@ public class Worker {
|
|||||||
ComputeType compute_method = ComputeType.CPU;
|
ComputeType compute_method = ComputeType.CPU;
|
||||||
Configuration config = new Configuration(null, login, password);
|
Configuration config = new Configuration(null, login, password);
|
||||||
config.setPrintLog(print_log);
|
config.setPrintLog(print_log);
|
||||||
|
config.setUsePriority(priority);
|
||||||
|
|
||||||
if (cache_dir != null) {
|
if (cache_dir != null) {
|
||||||
File a_dir = new File(cache_dir);
|
File a_dir = new File(cache_dir);
|
||||||
|
|||||||
Reference in New Issue
Block a user