Skip to content

Commit

Permalink
Update physical_plans.go
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzf678 committed Nov 1, 2022
1 parent ea6b9c8 commit 072fd6d
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions planner/core/physical_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ type tableScanAndPartitionInfo struct {
partitionInfo PartitionInfo
}

// MemoryUsage return the memory usage of tableScanAndPartitionInfo
func (t *tableScanAndPartitionInfo) MemoryUsage() (sum int64) {
if t == nil {
return
}

sum += t.partitionInfo.MemoryUsage()
if t.tableScan != nil {
sum += t.tableScan.MemoryUsage()
}
return
}

// ReadReqType is the read request type of the operator. Currently, only PhysicalTableReader uses this.
type ReadReqType uint8

Expand Down Expand Up @@ -200,8 +213,8 @@ func (p *PhysicalTableReader) MemoryUsage() (sum int64) {
for _, plan := range p.TablePlans {
sum += plan.MemoryUsage()
}
for _, pInfos := range p.PartitionInfos {
sum += pInfos.tableScan.MemoryUsage() + pInfos.partitionInfo.MemoryUsage()
for _, pInfo := range p.PartitionInfos {
sum += pInfo.MemoryUsage()
}
return
}
Expand Down Expand Up @@ -941,7 +954,7 @@ func (ts *PhysicalTableScan) MemoryUsage() (sum int64) {
}

sum = emptyPhysicalTableScanSize + ts.physicalSchemaProducer.MemoryUsage() + ts.DBName.MemoryUsage() +
int64(cap(ts.HandleIdx))*size.SizeOfInt + ts.PartitionInfo.MemoryUsage()
int64(cap(ts.HandleIdx))*size.SizeOfInt + ts.PartitionInfo.MemoryUsage() + int64(len(ts.rangeInfo))
if ts.TableAsName != nil {
sum += ts.TableAsName.MemoryUsage()
}
Expand All @@ -961,7 +974,6 @@ func (ts *PhysicalTableScan) MemoryUsage() (sum int64) {
for _, rang := range ts.Ranges {
sum += rang.MemUsage()
}
sum += int64(len(ts.rangeInfo))
for _, col := range ts.tblCols {
sum += col.MemoryUsage()
}
Expand Down Expand Up @@ -1458,8 +1470,6 @@ func (p *PhysicalExchangeReceiver) GetExchangeSender() *PhysicalExchangeSender {
return p.children[0].(*PhysicalExchangeSender)
}

const emptyMPPTaskSize = int64(unsafe.Sizeof(mppTask{}))

// MemoryUsage return the memory usage of PhysicalExchangeReceiver
func (p *PhysicalExchangeReceiver) MemoryUsage() (sum int64) {
if p == nil {
Expand Down

0 comments on commit 072fd6d

Please sign in to comment.