@@ -19,7 +19,6 @@ import (
19
19
"context"
20
20
"fmt"
21
21
"math"
22
- "runtime"
23
22
"slices"
24
23
"strconv"
25
24
"time"
@@ -121,6 +120,8 @@ var optRuleList = []logicalOptRule{
121
120
& resolveExpand {},
122
121
}
123
122
123
+ const initialMaxCores uint64 = 10000
124
+
124
125
// Interaction Rule List
125
126
/* The interaction rule will be trigger when it satisfies following conditions:
126
127
1. The related rule has been trigger and changed the plan
@@ -797,9 +798,7 @@ func (h *fineGrainedShuffleHelper) updateTarget(t shuffleTarget, p *basePhysical
797
798
h .plans = append (h .plans , p )
798
799
}
799
800
800
- // calculateTiFlashStreamCountUsingMinLogicalCores uses minimal logical cpu cores among tiflash servers, and divide by 2
801
- // return false, 0 if any err happens
802
- func calculateTiFlashStreamCountUsingMinLogicalCores (ctx context.Context , sctx PlanContext , serversInfo []infoschema.ServerInfo ) (bool , uint64 ) {
801
+ func getTiFlashServerMinLogicalCores (ctx context.Context , sctx PlanContext , serversInfo []infoschema.ServerInfo ) (bool , uint64 ) {
803
802
failpoint .Inject ("mockTiFlashStreamCountUsingMinLogicalCores" , func (val failpoint.Value ) {
804
803
intVal , err := strconv .Atoi (val .(string ))
805
804
if err == nil {
@@ -812,7 +811,6 @@ func calculateTiFlashStreamCountUsingMinLogicalCores(ctx context.Context, sctx P
812
811
if err != nil {
813
812
return false , 0
814
813
}
815
- var initialMaxCores uint64 = 10000
816
814
var minLogicalCores = initialMaxCores // set to a large enough value here
817
815
for _ , row := range rows {
818
816
if row [4 ].GetString () == "cpu-logical-cores" {
@@ -823,14 +821,19 @@ func calculateTiFlashStreamCountUsingMinLogicalCores(ctx context.Context, sctx P
823
821
}
824
822
}
825
823
// No need to check len(serersInfo) == serverCount here, since missing some servers' info won't affect the correctness
826
- if minLogicalCores > 1 && minLogicalCores != initialMaxCores {
827
- if runtime .GOARCH == "amd64" {
828
- // In most x86-64 platforms, `Thread(s) per core` is 2
829
- return true , minLogicalCores / 2
830
- }
831
- // ARM cpus don't implement Hyper-threading.
824
+ return true , minLogicalCores
825
+ }
826
+
827
+ // calculateTiFlashStreamCountUsingMinLogicalCores uses minimal logical cpu cores among tiflash servers
828
+ // return false, 0 if any err happens
829
+ func calculateTiFlashStreamCountUsingMinLogicalCores (ctx context.Context , sctx PlanContext , serversInfo []infoschema.ServerInfo ) (bool , uint64 ) {
830
+ valid , minLogicalCores := getTiFlashServerMinLogicalCores (ctx , sctx , serversInfo )
831
+ if ! valid {
832
+ return false , 0
833
+ }
834
+ if minLogicalCores != initialMaxCores {
835
+ // use logical core number as the stream count, the same as TiFlash's default max_threads: https://github.com/pingcap/tiflash/blob/v7.5.0/dbms/src/Interpreters/SettingsCommon.h#L166
832
836
return true , minLogicalCores
833
- // Other platforms are too rare to consider
834
837
}
835
838
836
839
return false , 0
0 commit comments