Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#48090
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
wshwsh12 authored and ti-chi-bot committed Oct 30, 2023
1 parent 62766de commit fbb623f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions executor/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,16 @@ func BenchmarkHashJoinExec(b *testing.B) {
b.Run(fmt.Sprintf("%v", cas), func(b *testing.B) {
benchmarkHashJoinExecWithCase(b, cas)
})

cols = []*types.FieldType{
types.NewFieldType(mysql.TypeLonglong),
}
cas = defaultHashJoinTestCase(cols, 0, false)
cas.keyIdx = []int{0}
cas.disk = true
b.Run(fmt.Sprintf("%v", cas), func(b *testing.B) {
benchmarkHashJoinExecWithCase(b, cas)
})
}

func BenchmarkOuterHashJoinExec(b *testing.B) {
Expand Down
10 changes: 8 additions & 2 deletions executor/hash_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,18 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk

// Some variables used for memTracker.
var (
<<<<<<< HEAD:executor/hash_table.go
matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize
lastChunkBufPointer *chunk.Chunk = nil
memDelta int64 = 0
needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoinMask
=======
matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize
needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoinMask
lastChunkBufPointer = c.chkBuf
memDelta int64
>>>>>>> f8ca23c6bfd (executor: reuse chunk for GetMatchedRowsAndPtrs calls (#48090)):pkg/executor/hash_table.go
)
c.chkBuf = nil
c.memTracker.Consume(-c.chkBufSizeForOneProbe)
if needTrackMemUsage {
c.memTracker.Consume(int64(cap(innerPtrs)) * rowPtrSize)
Expand All @@ -265,7 +271,7 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk
if err != nil {
return nil, nil, err
}
if needTrackMemUsage && c.chkBuf != lastChunkBufPointer && lastChunkBufPointer != nil {
if c.chkBuf != lastChunkBufPointer && lastChunkBufPointer != nil {
lastChunkSize := lastChunkBufPointer.MemoryUsage()
c.chkBufSizeForOneProbe += lastChunkSize
memDelta += lastChunkSize
Expand Down

0 comments on commit fbb623f

Please sign in to comment.