Skip to content

resource_control: add ru details in ExecDetails#1070

Merged
bufferflies merged 2 commits intotikv:masterfrom
glorv:ru-details
Dec 4, 2023
Merged

resource_control: add ru details in ExecDetails#1070
bufferflies merged 2 commits intotikv:masterfrom
glorv:ru-details

Conversation

@glorv
Copy link
Contributor

@glorv glorv commented Nov 30, 2023

cherry-pick #1032 to master and add RUWaitDuration to RUDetails. RUDetails is used in recording executing log and slow log in tidb.

@glorv
Copy link
Contributor Author

glorv commented Nov 30, 2023

@nolouch @bufferflies PTAL

@glorv
Copy link
Contributor Author

glorv commented Dec 1, 2023

/cc @JmPotato As we add ru metrics into ExecDetails, seems we can let explain analyze also depend on it and remove the global sync Map used in resourceInterceptor. Please help verify if I missed something.

}

consumption, penalty, priority, err := resourceControlInterceptor.OnRequestWait(ctx, resourceGroupName, reqInfo)
consumption, penalty, waitDuration, priority, err := resourceControlInterceptor.OnRequestWait(ctx, resourceGroupName, reqInfo)
Copy link
Contributor

Choose a reason for hiding this comment

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

how about use one struct ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if there is a best practice. The different between tuple and struct is not large, I see many other functions return multiple parameters.

if stmtExec := ctx.Value(util.ExecDetailsKey); stmtExec != nil {
detail := stmtExec.(*util.ExecDetails)
atomic.AddInt64(&detail.MilliRRU, int64(consumption.RRU*1000.0))
atomic.AddInt64(&detail.MilliRRU, int64(consumption.RRU*1000.0))
Copy link
Contributor

@bufferflies bufferflies Dec 1, 2023

Choose a reason for hiding this comment

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

why it needs to retry again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

retry what?

WaitRUDuration int64
// total read ans write ru in 1/1000
MilliRRU int64
MilliWRU int64
Copy link
Contributor

Choose a reason for hiding this comment

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

where does it use in this pr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return
}
if stmtExec := ctx.Value(util.ExecDetailsKey); stmtExec != nil {
detail := stmtExec.(*util.ExecDetails)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it maybe nil in some scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. If the value exists, it should not be nil, otherwise the context value should not exist.

detail := stmtExec.(*util.ExecDetails)
atomic.AddInt64(&detail.MilliRRU, int64(consumption.RRU*1000.0))
atomic.AddInt64(&detail.MilliWRU, int64(consumption.WRU*1000.0))
if waitDuration > time.Duration(0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what‘s the different if remove this condition? I think zero doesn't need to treat alone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the Duration is always 0 in OnResponse call, it's a very frequent value, so not need to do the atomic operation in this case. Though, the performance difference should be quite low.

@bufferflies
Copy link
Contributor

Rest LGTM, you need to sync the upstream.

WaitPDRespDuration int64
WaitRUDuration int64
// total read ans write ru in 1/1000
MilliRRU int64
Copy link
Contributor

@nolouch nolouch Dec 4, 2023

Choose a reason for hiding this comment

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

Is Milli for precision? I think it correspond to milliseconds, but this is multiplied by 1000.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe RRUx1000 :).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. naming similar to millisecond, not sure if it is the correct naming.

Signed-off-by: glorv <glorvs@163.com>
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@bufferflies bufferflies merged commit e80e9ca into tikv:master Dec 4, 2023
@glorv glorv deleted the ru-details branch December 4, 2023 07:44
iosmanthus pushed a commit to iosmanthus/client-go that referenced this pull request Dec 21, 2023
* collecting the RU information by pasing point through context.Value (tikv#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
nolouch pushed a commit to nolouch/client-go that referenced this pull request Feb 2, 2024
* collecting the RU information by pasing point through context.Value (tikv#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
glorv added a commit that referenced this pull request Feb 18, 2024
…#1151)

* resource_control: add ru details in ExecDetails (#1070)

* collecting the RU information by pasing point through context.Value (#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>

* use latest pd-client of release-7.5

Signed-off-by: nolouch <nolouch@gmail.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: nolouch <nolouch@gmail.com>
Co-authored-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
zeminzhou added a commit to zeminzhou/client-go that referenced this pull request Feb 28, 2024
* collecting the RU information by pasing point through context.Value (tikv#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
zeminzhou added a commit to zeminzhou/client-go that referenced this pull request Feb 28, 2024
* collecting the RU information by pasing point through context.Value (tikv#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
zeminzhou added a commit to zeminzhou/client-go that referenced this pull request Feb 28, 2024
* collecting the RU information by pasing point through context.Value (tikv#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
zeminzhou added a commit to zeminzhou/client-go that referenced this pull request Feb 28, 2024
) (tikv#1151)

* resource_control: add ru details in ExecDetails (tikv#1070)

* collecting the RU information by pasing point through context.Value (tikv#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>

* use latest pd-client of release-7.5

Signed-off-by: nolouch <nolouch@gmail.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Signed-off-by: nolouch <nolouch@gmail.com>
Co-authored-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: zzm <zhouzemin@pingcap.com>
zeminzhou added a commit to zeminzhou/client-go that referenced this pull request Feb 28, 2024
* collecting the RU information by pasing point through context.Value (tikv#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Signed-off-by: zzm <zhouzemin@pingcap.com>
zeminzhou added a commit to zeminzhou/client-go that referenced this pull request Mar 13, 2024
* collecting the RU information by pasing point through context.Value (tikv#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: iosmanthus <myosmanthustree@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants