Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executor: support hash join spill #55950

Merged
merged 65 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
715e03f
save
xzhangxian1008 Sep 5, 2024
acef9a7
Merge branch 'master' into hash-join-spill-v2
xzhangxian1008 Sep 5, 2024
2b382c5
save
xzhangxian1008 Sep 5, 2024
287e2f9
fix ut
xzhangxian1008 Sep 5, 2024
b032126
add test and fix
xzhangxian1008 Sep 6, 2024
37a08c6
add more codes
xzhangxian1008 Sep 6, 2024
9f994a8
fix bugs
xzhangxian1008 Sep 6, 2024
3c6eaf7
fix bugs
xzhangxian1008 Sep 9, 2024
08ef531
fix bugs and add tests
xzhangxian1008 Sep 9, 2024
4fb8494
update bazel
xzhangxian1008 Sep 9, 2024
47bf0e7
merge
xzhangxian1008 Sep 9, 2024
12047df
rename
xzhangxian1008 Sep 10, 2024
6753db4
rename
xzhangxian1008 Sep 10, 2024
b152d87
fix
xzhangxian1008 Sep 11, 2024
d59ccaa
remove useless function
xzhangxian1008 Sep 11, 2024
56018b6
address some comments
xzhangxian1008 Sep 13, 2024
397bfd8
address comments
xzhangxian1008 Sep 13, 2024
7cc6f4d
tweaking
xzhangxian1008 Sep 14, 2024
ae866e0
address some comments
xzhangxian1008 Sep 14, 2024
9a7a934
address comments
xzhangxian1008 Sep 18, 2024
2c3ede3
tweaking
xzhangxian1008 Sep 18, 2024
f275846
add quick exit
xzhangxian1008 Sep 18, 2024
c93632b
tweaking
xzhangxian1008 Sep 19, 2024
1cb701f
fix gc crash bug
xzhangxian1008 Sep 19, 2024
645d6e3
check chk.Sel()
xzhangxian1008 Sep 19, 2024
80d863f
Merge branch 'master' into hash-join-spill-v2
xzhangxian1008 Sep 20, 2024
d233d06
the tweaking of fallback action
xzhangxian1008 Sep 20, 2024
47ba38d
fix bug
xzhangxian1008 Sep 20, 2024
2509a40
address comments
xzhangxian1008 Sep 23, 2024
e017c8c
fix ci
xzhangxian1008 Sep 23, 2024
e4f12e9
fix uint64
xzhangxian1008 Sep 23, 2024
18453f8
remove pool
xzhangxian1008 Sep 23, 2024
28f79bc
fix ci
xzhangxian1008 Sep 23, 2024
bbcf02c
fix ut
xzhangxian1008 Sep 23, 2024
da359e4
add test
xzhangxian1008 Sep 23, 2024
1035ee6
fix ci
xzhangxian1008 Sep 23, 2024
47c9644
remove useless test
xzhangxian1008 Sep 23, 2024
27c5118
remove useless test result
xzhangxian1008 Sep 23, 2024
d9d7dc9
tweaking
xzhangxian1008 Sep 23, 2024
f40b9fe
fix test
xzhangxian1008 Sep 23, 2024
d11c63f
tweaking
xzhangxian1008 Sep 24, 2024
38a3b26
fix
xzhangxian1008 Sep 24, 2024
e3934b1
move test to ut
xzhangxian1008 Sep 24, 2024
080ef8c
update bazel
xzhangxian1008 Sep 24, 2024
d77b37a
rename
xzhangxian1008 Sep 24, 2024
546060a
address comments
xzhangxian1008 Sep 25, 2024
846fedf
fix ci
xzhangxian1008 Sep 25, 2024
3328492
add
xzhangxian1008 Sep 25, 2024
e50ed2c
merge
xzhangxian1008 Sep 25, 2024
bb3edb6
enable v2
xzhangxian1008 Sep 25, 2024
0cce782
fix ci
xzhangxian1008 Sep 25, 2024
978cd1e
fix
xzhangxian1008 Sep 25, 2024
a4627bb
tweaking
xzhangxian1008 Sep 25, 2024
c4f2497
tweaking
xzhangxian1008 Sep 25, 2024
d2c5445
fix
xzhangxian1008 Sep 25, 2024
35088ae
fix test
xzhangxian1008 Sep 26, 2024
6b23b74
comment
xzhangxian1008 Sep 27, 2024
1dbd75b
resolve comment
xzhangxian1008 Oct 12, 2024
128d6eb
Merge branch 'master' into hash-join-spill-v2
xzhangxian1008 Oct 12, 2024
7d575ad
add comment
xzhangxian1008 Oct 12, 2024
4c178c0
Merge branch 'master' into hash-join-spill-v2
xzhangxian1008 Oct 16, 2024
1847c14
tweaking
xzhangxian1008 Oct 17, 2024
b81eec6
tweaking
xzhangxian1008 Oct 18, 2024
1124a31
update
xzhangxian1008 Oct 18, 2024
e4f4127
tweaking
xzhangxian1008 Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/executor/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ func prepare4HashJoinV2(testCase *hashJoinTestCase, innerExec, outerExec exec.Ex
for i := 0; i < testCase.concurrency; i++ {
e.ProbeWorkers[i] = &join.ProbeWorkerV2{
HashJoinCtx: e.HashJoinCtxV2,
JoinProbe: join.NewJoinProbe(e.HashJoinCtxV2, uint(i), testCase.joinType, probeKeysColIdx, joinedTypes, probeKeyTypes, false),
JoinProbe: join.NewJoinProbe(e.HashJoinCtxV2, uint(i), testCase.joinType, probeKeysColIdx, joinedTypes, probeKeyTypes, false, nil),
}
e.ProbeWorkers[i].WorkerID = uint(i)
e.BuildWorkers[i] = join.NewJoinBuildWorkerV2(e.HashJoinCtxV2, uint(i), innerExec, joinKeysColIdx, innerTypes)
Expand Down
2 changes: 1 addition & 1 deletion pkg/executor/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,7 @@ func (b *executorBuilder) buildHashJoinV2(v *plannercore.PhysicalHashJoin) exec.
for i := uint(0); i < e.Concurrency; i++ {
e.ProbeWorkers[i] = &join.ProbeWorkerV2{
HashJoinCtx: e.HashJoinCtxV2,
JoinProbe: join.NewJoinProbe(e.HashJoinCtxV2, i, v.JoinType, probeKeyColIdx, joinedTypes, e.ProbeKeyTypes, e.RightAsBuildSide),
JoinProbe: join.NewJoinProbe(e.HashJoinCtxV2, i, v.JoinType, probeKeyColIdx, joinedTypes, e.ProbeKeyTypes, e.RightAsBuildSide, e.ProbeSideTupleFetcher.ProbeSideExec.RetFieldTypes()),
}
e.ProbeWorkers[i].WorkerID = i

Expand Down
47 changes: 37 additions & 10 deletions pkg/executor/internal/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ type MockDataSourceParameters struct {
Ndvs []int
Orders []bool
Rows int

// Sometimes, user wants to manually provide test data
// and he can save provided test data at here.
Datums [][]any

HasSel bool
}

// MockDataSource mocks data source
Expand All @@ -73,6 +79,7 @@ func (mds *MockDataSource) GenColDatums(col int) (results []any) {
ndv = mds.P.Ndvs[col]
}
results = make([]any, 0, rows)

if ndv == 0 {
if mds.P.GenDataFunc == nil {
for i := 0; i < rows; i++ {
Expand All @@ -84,20 +91,28 @@ func (mds *MockDataSource) GenColDatums(col int) (results []any) {
}
}
} else {
datumSet := make(map[string]bool, ndv)
datums := make([]any, 0, ndv)
for len(datums) < ndv {
d := mds.RandDatum(typ)
str := fmt.Sprintf("%v", d)
if datumSet[str] {
continue
datums := make([]any, 0, max(ndv, 0))
if ndv == -1 {
if mds.P.Datums[col] == nil {
panic("need to provid data")
}

datums = mds.P.Datums[col]
} else {
datumSet := make(map[string]bool, ndv)
for len(datums) < ndv {
d := mds.RandDatum(typ)
str := fmt.Sprintf("%v", d)
if datumSet[str] {
continue
}
datumSet[str] = true
datums = append(datums, d)
}
datumSet[str] = true
datums = append(datums, d)
}

for i := 0; i < rows; i++ {
val, err := rand.Int(rand.Reader, big.NewInt(int64(ndv)))
val, err := rand.Int(rand.Reader, big.NewInt(int64(len(datums))))
if err != nil {
panic("Fail to generate int number")
}
Expand Down Expand Up @@ -272,6 +287,18 @@ func BuildMockDataSource(opt MockDataSourceParameters) *MockDataSource {
}
}
}

if opt.HasSel {
for _, chk := range m.GenData {
rowNum := chk.NumRows()
sel := make([]int, 0, rowNum/2)
for i := mathrand.Int31n(2); int(i) < rowNum; i += 2 {
sel = append(sel, int(i))
}
chk.SetSel(sel)
}
}

return m
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/executor/join/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ go_library(
"base_join_probe.go",
"concurrent_map.go",
"hash_join_base.go",
"hash_join_spill.go",
"hash_join_spill_helper.go",
"hash_join_test_util.go",
"hash_join_v1.go",
"hash_join_v2.go",
"hash_table_v1.go",
Expand All @@ -28,6 +31,7 @@ go_library(
"//pkg/executor/aggregate",
"//pkg/executor/internal/applycache",
"//pkg/executor/internal/exec",
"//pkg/executor/internal/testutil",
"//pkg/executor/internal/vecgroupchecker",
"//pkg/executor/unionexec",
"//pkg/expression",
Expand Down Expand Up @@ -58,6 +62,7 @@ go_library(
"//pkg/util/syncutil",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_stretchr_testify//require",
"@org_uber_go_zap//:zap",
],
)
Expand All @@ -73,12 +78,14 @@ go_test(
"index_lookup_join_test.go",
"index_lookup_merge_join_test.go",
"inner_join_probe_test.go",
"inner_join_spill_test.go",
"join_row_table_test.go",
"join_stats_test.go",
"join_table_meta_test.go",
"joiner_test.go",
"left_outer_join_probe_test.go",
"merge_join_test.go",
"outer_join_spill_test.go",
"right_outer_join_probe_test.go",
"row_table_builder_test.go",
"tagged_ptr_test.go",
Expand Down
Loading