mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Fixed startup delay due to TCMalloc EstimateCyclesPerSecond
This commit is contained in:
parent
a414045e96
commit
310efb5c0c
1 changed files with 15 additions and 9 deletions
|
@ -321,7 +321,7 @@ static void InitializeSystemInfo() {
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
perror(pname);
|
perror(pname);
|
||||||
if (!saw_mhz) {
|
if (!saw_mhz) {
|
||||||
cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
|
//cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
|
||||||
}
|
}
|
||||||
return; // TODO: use generic tester instead?
|
return; // TODO: use generic tester instead?
|
||||||
}
|
}
|
||||||
|
@ -398,7 +398,7 @@ static void InitializeSystemInfo() {
|
||||||
cpuinfo_cycles_per_second = bogo_clock;
|
cpuinfo_cycles_per_second = bogo_clock;
|
||||||
} else {
|
} else {
|
||||||
// If we don't even have bogomips, we'll use the slow estimation.
|
// If we don't even have bogomips, we'll use the slow estimation.
|
||||||
cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
|
//cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cpuinfo_cycles_per_second == 0.0) {
|
if (cpuinfo_cycles_per_second == 0.0) {
|
||||||
|
@ -430,19 +430,19 @@ static void InitializeSystemInfo() {
|
||||||
if ( sysctlbyname(sysctl_path, &hz, &sz, NULL, 0) != 0 ) {
|
if ( sysctlbyname(sysctl_path, &hz, &sz, NULL, 0) != 0 ) {
|
||||||
fprintf(stderr, "Unable to determine clock rate from sysctl: %s: %s\n",
|
fprintf(stderr, "Unable to determine clock rate from sysctl: %s: %s\n",
|
||||||
sysctl_path, strerror(errno));
|
sysctl_path, strerror(errno));
|
||||||
cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
|
//cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
|
||||||
} else {
|
} else {
|
||||||
cpuinfo_cycles_per_second = hz;
|
cpuinfo_cycles_per_second = hz;
|
||||||
}
|
}
|
||||||
// TODO(csilvers): also figure out cpuinfo_num_cpus
|
// TODO(csilvers): also figure out cpuinfo_num_cpus
|
||||||
|
|
||||||
#elif defined(PLATFORM_WINDOWS)
|
#elif defined(PLATFORM_WINDOWS)
|
||||||
# pragma comment(lib, "shlwapi.lib") // for SHGetValue()
|
//# pragma comment(lib, "shlwapi.lib") // for SHGetValue()
|
||||||
// In NT, read MHz from the registry. If we fail to do so or we're in win9x
|
// In NT, read MHz from the registry. If we fail to do so or we're in win9x
|
||||||
// then make a crude estimate.
|
// then make a crude estimate.
|
||||||
OSVERSIONINFO os;
|
// OSVERSIONINFO os;
|
||||||
os.dwOSVersionInfoSize = sizeof(os);
|
// os.dwOSVersionInfoSize = sizeof(os);
|
||||||
DWORD data, data_size = sizeof(data);
|
// DWORD data, data_size = sizeof(data);
|
||||||
|
|
||||||
//BCF
|
//BCF
|
||||||
/*if (GetVersionEx(&os) &&
|
/*if (GetVersionEx(&os) &&
|
||||||
|
@ -452,7 +452,7 @@ static void InitializeSystemInfo() {
|
||||||
"~MHz", NULL, &data, &data_size)))
|
"~MHz", NULL, &data, &data_size)))
|
||||||
cpuinfo_cycles_per_second = (int64)data * (int64)(1000 * 1000); // was mhz
|
cpuinfo_cycles_per_second = (int64)data * (int64)(1000 * 1000); // was mhz
|
||||||
else*/
|
else*/
|
||||||
cpuinfo_cycles_per_second = EstimateCyclesPerSecond(500); // TODO <500?
|
//cpuinfo_cycles_per_second = EstimateCyclesPerSecond(500); // TODO <500?
|
||||||
|
|
||||||
// Get the number of processors.
|
// Get the number of processors.
|
||||||
SYSTEM_INFO info;
|
SYSTEM_INFO info;
|
||||||
|
@ -485,12 +485,18 @@ static void InitializeSystemInfo() {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Generic cycles per second counter
|
// Generic cycles per second counter
|
||||||
cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
|
//cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
double CyclesPerSecond(void) {
|
double CyclesPerSecond(void) {
|
||||||
InitializeSystemInfo();
|
InitializeSystemInfo();
|
||||||
|
|
||||||
|
if (cpuinfo_cycles_per_second == 1.0)
|
||||||
|
{
|
||||||
|
cpuinfo_cycles_per_second = EstimateCyclesPerSecond(500);
|
||||||
|
}
|
||||||
|
|
||||||
return cpuinfo_cycles_per_second;
|
return cpuinfo_cycles_per_second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue