mirror of https://github.com/BOINC/boinc.git
Fixed performance in Windows.
Additionally, the VM can be throttled by parsing in the wrapper the <max_vm_cpu_pct> specific project preference. svn path=/trunk/boinc/; revision=23976
This commit is contained in:
parent
609d5665cc
commit
6d104573c6
|
@ -26,7 +26,6 @@
|
|||
// Contributor: Daniel Lombraña González <teleyinex AT gmail DOT com>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
@ -71,8 +70,8 @@
|
|||
#define POLL_PERIOD 1.0
|
||||
#define MESSAGE "CPUTIME"
|
||||
#define YEAR_SECS 365*24*60*60
|
||||
#define BUFSIZE 4096
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
struct VM {
|
||||
|
@ -100,7 +99,9 @@ struct VM {
|
|||
int send_cputime_message();
|
||||
void poll();
|
||||
};
|
||||
|
||||
void write_cputime(double);
|
||||
|
||||
APP_INIT_DATA aid;
|
||||
|
||||
|
||||
|
@ -193,18 +194,30 @@ bool vbm_popen(string arg_list,
|
|||
}
|
||||
return false;
|
||||
}
|
||||
while(1)
|
||||
{
|
||||
GetExitCodeProcess(pi.hProcess,&exit); //while the process is running
|
||||
if (exit != STILL_ACTIVE)
|
||||
break;
|
||||
}
|
||||
//while(1)
|
||||
//{
|
||||
// GetExitCodeProcess(pi.hProcess,&exit); //while the process is running
|
||||
// if (exit != STILL_ACTIVE)
|
||||
// break;
|
||||
//}
|
||||
|
||||
// Wait until process exists.
|
||||
WaitForSingleObject( pi.hProcess, INFINITE );
|
||||
|
||||
// Close process and thread handles.
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(pi.hProcess);
|
||||
|
||||
if(buffer!=NULL){
|
||||
memset(buffer,0,nSize);
|
||||
DWORD bread;
|
||||
BOOL bSuccess = false;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
ReadFile(read_stdout,buffer,nSize-1,&bread,NULL);
|
||||
if ( ! bSuccess || bread == 0 ) break;
|
||||
}
|
||||
// buffer[bread]=0;
|
||||
CloseHandle(newstdout);
|
||||
CloseHandle(read_stdout);
|
||||
|
@ -360,10 +373,17 @@ void VM::throttle()
|
|||
// Check the BOINC CPU preferences for running the VM accordingly
|
||||
string arg_list = "";
|
||||
boinc_get_init_data(aid);
|
||||
fprintf(stderr,"INFO: Maximum usage of CPU: %f\n", aid.global_prefs.cpu_usage_limit);
|
||||
fprintf(stderr,"INFO: Setting how much CPU time the virtual CPU can use: %i\n", int(aid.global_prefs.cpu_usage_limit));
|
||||
double max_vm_cpu_pct = 100.0;
|
||||
|
||||
if (aid.project_preferences)
|
||||
{
|
||||
if (!aid.project_preferences) return;
|
||||
if (parse_double(aid.project_preferences, "<max_vm_cpu_pct>", max_vm_cpu_pct))
|
||||
{
|
||||
fprintf(stderr,"INFO: Maximum usage of CPU: %f\n", max_vm_cpu_pct);
|
||||
fprintf(stderr,"INFO: Setting how much CPU time the virtual CPU can use: %i\n", int(max_vm_cpu_pct));
|
||||
std::stringstream out;
|
||||
out << int(aid.global_prefs.cpu_usage_limit);
|
||||
out << int(max_vm_cpu_pct);
|
||||
|
||||
arg_list = " controlvm " + virtual_machine_name + " cpuexecutioncap " + out.str();
|
||||
if (!vbm_popen(arg_list))
|
||||
|
@ -375,6 +395,10 @@ void VM::throttle()
|
|||
fprintf(stderr,"INFO: Success!\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void VM::start(bool vrde=false, bool headless=false) {
|
||||
|
|
Loading…
Reference in New Issue