浏览代码

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 年之前
父节点
当前提交
1cf3d44a19
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 4 1
      src/core/UPCOperationsBlockValidator.pas
  2. 4 1
      src/core/UPCOperationsSignatureValidator.pas

+ 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