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
address comment
  • Loading branch information
XuHuaiyu committed Dec 26, 2019
commit 3fb96e98164bde60ae36203dd14d3d3dd971487a
5 changes: 1 addition & 4 deletions session/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,7 @@ func (s *session) getTxnFuture(ctx context.Context) *txnFuture {

// StmtCommit implements the sessionctx.Context interface.
func (s *session) StmtCommit(memTracker *memory.Tracker) error {
Copy link
Member

@jackysp jackysp Dec 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The statement is finished and the memory is allocated when StmtCommit, I think it is meanless. Consume it at

return st.buf.Set(k, v)
.

Copy link
Contributor Author

@XuHuaiyu XuHuaiyu Dec 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But stmtBuffer can be GCed after be written to txnBuffer?

defer func() {
s.txn.cleanup()
memTracker.Consume(int64(-s.txn.Size()))
}()
defer s.txn.cleanup()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we follow code logic, this defer maybe need memTracker.Consume(-int64(txn.Size())), before this line we have put all data from stmt buffer into transaction buffer, and this line will cleanup stmt buffer

st := &s.txn
txnSize := st.Transaction.Size()
var count int
Expand Down