From db290b19ed20079c0bea432931881b3c96da0660 Mon Sep 17 00:00:00 2001 From: wshwsh12 <793703860@qq.com> Date: Fri, 10 Feb 2023 14:38:12 +0800 Subject: [PATCH 1/3] fix --- executor/hash_table.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/executor/hash_table.go b/executor/hash_table.go index 57d4519be50b8..41b9ca7edb6d2 100644 --- a/executor/hash_table.go +++ b/executor/hash_table.go @@ -241,10 +241,14 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize lastChunkBufPointer *chunk.Chunk = nil memDelta int64 = 0 + trackMemUsage = cap(innerPtrs) > signalCheckpointForJoin ) c.chkBuf = nil - c.memTracker.Consume(-c.chkBufSizeForOneProbe + int64(cap(innerPtrs))*rowPtrSize) - defer c.memTracker.Consume(-int64(cap(innerPtrs))*rowPtrSize + memDelta) + c.memTracker.Consume(-c.chkBufSizeForOneProbe) + if trackMemUsage { + c.memTracker.Consume(int64(cap(innerPtrs)) * rowPtrSize) + defer c.memTracker.Consume(-int64(cap(innerPtrs))*rowPtrSize + memDelta) + } c.chkBufSizeForOneProbe = 0 for i, ptr := range innerPtrs { @@ -257,13 +261,13 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk if err != nil { return nil, nil, err } - if c.chkBuf != lastChunkBufPointer && lastChunkBufPointer != nil { + if trackMemUsage && c.chkBuf != lastChunkBufPointer && lastChunkBufPointer != nil { lastChunkSize := lastChunkBufPointer.MemoryUsage() c.chkBufSizeForOneProbe += lastChunkSize memDelta += lastChunkSize } lastChunkBufPointer = c.chkBuf - if i&signalCheckpointForJoin == 0 { + if trackMemUsage && (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 From c171c77957e4b722f6534fc2b66fd7a539c58cd7 Mon Sep 17 00:00:00 2001 From: wshwsh12 <793703860@qq.com> Date: Fri, 10 Feb 2023 16:28:42 +0800 Subject: [PATCH 2/3] rename --- executor/hash_table.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/executor/hash_table.go b/executor/hash_table.go index 41b9ca7edb6d2..bc6f62f64f3be 100644 --- a/executor/hash_table.go +++ b/executor/hash_table.go @@ -240,12 +240,12 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk var ( matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize lastChunkBufPointer *chunk.Chunk = nil - memDelta int64 = 0 - trackMemUsage = cap(innerPtrs) > signalCheckpointForJoin + memDelta int64 = 0 + needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoin ) c.chkBuf = nil c.memTracker.Consume(-c.chkBufSizeForOneProbe) - if trackMemUsage { + if needTrackMemUsage { c.memTracker.Consume(int64(cap(innerPtrs)) * rowPtrSize) defer c.memTracker.Consume(-int64(cap(innerPtrs))*rowPtrSize + memDelta) } @@ -261,13 +261,13 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk if err != nil { return nil, nil, err } - if trackMemUsage && c.chkBuf != lastChunkBufPointer && lastChunkBufPointer != nil { + if needTrackMemUsage && c.chkBuf != lastChunkBufPointer && lastChunkBufPointer != nil { lastChunkSize := lastChunkBufPointer.MemoryUsage() c.chkBufSizeForOneProbe += lastChunkSize memDelta += lastChunkSize } lastChunkBufPointer = c.chkBuf - if trackMemUsage && (i&signalCheckpointForJoin == (signalCheckpointForJoin - 1)) { + 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 From d09a97ceca6cbcc422770caa371eefd8376b70d9 Mon Sep 17 00:00:00 2001 From: wshwsh12 <793703860@qq.com> Date: Fri, 10 Feb 2023 16:28:56 +0800 Subject: [PATCH 3/3] rename --- executor/hash_table.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executor/hash_table.go b/executor/hash_table.go index bc6f62f64f3be..2bfdc05c69244 100644 --- a/executor/hash_table.go +++ b/executor/hash_table.go @@ -240,8 +240,8 @@ func (c *hashRowContainer) GetMatchedRowsAndPtrs(probeKey uint64, probeRow chunk var ( matchedDataSize = int64(cap(matched))*rowSize + int64(cap(matchedPtrs))*rowPtrSize lastChunkBufPointer *chunk.Chunk = nil - memDelta int64 = 0 - needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoin + memDelta int64 = 0 + needTrackMemUsage = cap(innerPtrs) > signalCheckpointForJoin ) c.chkBuf = nil c.memTracker.Consume(-c.chkBufSizeForOneProbe)