Browse Source

Multithreads sign/block validators change on 2 cpu's

When only 2 cpu's available, will use both, otherwise will use all cpu's-1 (max of 7 cpu's)
PascalCoin 6 years ago
parent
commit
1cf3d44a19

+ 4 - 1
src/core/UPCOperationsBlockValidator.pas

@@ -160,8 +160,11 @@ begin
   if _Cpus<=0 then begin
   if _Cpus<=0 then begin
     _Cpus := TLogicalCPUCount.GetLogicalCPUCount;
     _Cpus := TLogicalCPUCount.GetLogicalCPUCount;
   end;
   end;
-  LMaxThreads := _Cpus-1;
+  if (_Cpus>2) then LMaxThreads := _Cpus-1
+  else LMaxThreads := _Cpus;
   if (LMaxThreads<=0) then LMaxThreads := 1;
   if (LMaxThreads<=0) then LMaxThreads := 1;
+  if (LMaxThreads>7) then LMaxThreads := 7;
+
   LThreads := TList<TPCOperationsBlockValidatorThread>.Create;
   LThreads := TList<TPCOperationsBlockValidatorThread>.Create;
   Try
   Try
     // Init values
     // Init values

+ 4 - 1
src/core/UPCOperationsSignatureValidator.pas

@@ -266,8 +266,11 @@ begin
   if _Cpus<=0 then begin
   if _Cpus<=0 then begin
     _Cpus := TLogicalCPUCount.GetLogicalCPUCount;
     _Cpus := TLogicalCPUCount.GetLogicalCPUCount;
   end;
   end;
-  LMaxThreads := _Cpus-1;
+  if (_Cpus>2) then LMaxThreads := _Cpus-1
+  else LMaxThreads := _Cpus;
   if (LMaxThreads<=0) then LMaxThreads := 1;
   if (LMaxThreads<=0) then LMaxThreads := 1;
+  if (LMaxThreads>7) then LMaxThreads := 7;
+
   LThreads := TList<TPCOperationsSignatureValidatorThread>.Create;
   LThreads := TList<TPCOperationsSignatureValidatorThread>.Create;
   Try
   Try
     // Init values
     // Init values