diff --git a/executor/hash_table.go b/executor/hash_table.go index 50acc4447f4df..2bfdc05c69244 100644 --- a/executor/hash_table.go +++ b/executor/hash_table.go @@ -214,8 +214,8 @@ func (c *hashRowContainer) GetAllMatchedRows(probeHCtx *hashContext, probeSideRo return matched, nil } -// signalCheckpointForJoinMask indicates the times of row probe that a signal detection will be triggered. -const signalCheckpointForJoinMask int = 1<<14 - 1 +// signalCheckpointForJoin indicates the times of row probe that a signal detection will be triggered. +const signalCheckpointForJoin int = 1 << 14 // rowSize is the size of Row. const rowSize = int64(unsafe.Sizeof(chunk.Row{})) @@ -241,7 +241,7 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize lastChunkBufPointer *chunk.Chunk = nil memDelta int64 = 0 - needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoinMask + needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoin ) c.chkBuf = nil c.memTracker.Consume(-c.chkBufSizeForOneProbe) @@ -267,7 +267,7 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk memDelta += lastChunkSize } lastChunkBufPointer = c.chkBuf - if needTrackMemUsage && (i&signalCheckpointForJoinMask == signalCheckpointForJoinMask) { + if needTrackMemUsage && (i&signalCheckpointForJoin == (signalCheckpointForJoin - 1)) { // Trigger Consume for checking the OOM Action signal memDelta += int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize - matchedDataSize matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize