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

*: add memory tracker for InsertExec and ReplaceExec #14179

Merged
merged 28 commits into from
Dec 30, 2019
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Merge branch 'master' of https://github.com/pingcap/tidb into trace-w…
…rite-memory
  • Loading branch information
XuHuaiyu committed Dec 24, 2019
commit a9f2e5bdada5997ee5cfda48397ce4e3a9fff8a1
14 changes: 9 additions & 5 deletions types/datum.go
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,11 @@ func ChangeReverseResultByUpperLowerBound(
return d, nil
}

const sizeOfEmptyDatum = int(unsafe.Sizeof(Datum{}))
const (
sizeOfEmptyDatum = int(unsafe.Sizeof(Datum{}))
sizeOfMysqlTime = int(unsafe.Sizeof(Time{}))
sizeOfMyDecimal = MyDecimalStructSize
)

// EstimatedMemUsage returns the estimated bytes consumed of a one-dimensional
// or two-dimensional datum array.
Expand All @@ -2071,12 +2075,12 @@ func EstimatedMemUsage(array []Datum, numOfRows int) int64 {
var bytesConsumed int
for _, d := range array {
switch d.Kind() {
case KindString, KindBytes, KindBinaryLiteral, KindMysqlJSON, KindMysqlEnum, KindMysqlSet, KindMysqlBit:
bytesConsumed += len(d.b)
case KindMysqlDecimal:
bytesConsumed += int(unsafe.Sizeof(d.GetMysqlDecimal()))
bytesConsumed += sizeOfMyDecimal
case KindMysqlTime:
bytesConsumed += int(unsafe.Sizeof(d.GetMysqlTime()))
bytesConsumed += sizeOfMysqlTime
default:
bytesConsumed += len(d.b)
}
}
bytesConsumed += len(array) * sizeOfEmptyDatum
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.