fix group clock unlimited

This commit is contained in:
obdev 2024-12-17 08:45:38 +00:00 committed by ob-robot
parent 566a745c7a
commit b187dbc87e
3 changed files with 20 additions and 2 deletions

View File

@ -297,7 +297,7 @@ int ObTenantIOClock::calc_phyqueue_clock(ObPhyQueue *phy_queue, ObIORequest &req
}
} else {
// min_iops of group
mclock->reservation_clock_.atom_update(current_ts - PHY_QUEUE_BURST_USEC, iops_scale, phy_queue->reservation_ts_);
mclock->reservation_clock_.atom_update_reserve(current_ts - PHY_QUEUE_BURST_USEC, iops_scale, phy_queue->reservation_ts_);
}
// iops/bandwidth weight of tenant & group, TODO fengshuo.fs: THIS IS NOT CORRECT
mclock->proportion_clock_.atom_update(current_ts - PHY_QUEUE_BURST_USEC, iops_scale, phy_queue->proportion_ts_);

View File

@ -2288,6 +2288,23 @@ int64_t ObTenantIOConfig::to_string(char* buf, const int64_t buf_len) const
}
/****************** IOClock **********************/
void ObAtomIOClock::atom_update_reserve(const int64_t current_ts, const double iops_scale, int64_t &deadline_ts)
{
if (0 == iops_scale * iops_) {
deadline_ts = INT64_MAX;
} else {
const int64_t delta_ns = 1000L * 1000L * 1000L / (iops_scale * iops_);
int64_t ov = ATOMIC_LOAD(&last_ns_);
int64_t nv = 0;
int64_t tv = max(current_ts * 1000L, ov + delta_ns);
while (ov != (nv = ATOMIC_VCAS(&last_ns_, ov, tv))) {
ov = nv;
tv = max(current_ts * 1000L, ov + delta_ns);
}
deadline_ts = tv / 1000L;
}
}
void ObAtomIOClock::atom_update(const int64_t current_ts, const double iops_scale, int64_t &deadline_ts)
{
if (0 == iops_scale * iops_) {
@ -2309,7 +2326,7 @@ void ObAtomIOClock::compare_and_update(const int64_t current_ts, const double io
{
int64_t tmp = 0;
atom_update(current_ts, iops_scale, tmp);
deadline_ts = (INT64_MAX == deadline_ts) ? current_ts : max(deadline_ts, tmp);
deadline_ts = (INT64_MAX == deadline_ts) ? tmp : max(deadline_ts, tmp);
}
void ObAtomIOClock::reset()

View File

@ -808,6 +808,7 @@ struct ObAtomIOClock final
{
ObAtomIOClock() : iops_(0), last_ns_(0)
{}
void atom_update_reserve(const int64_t current_ts, const double iops_scale, int64_t &deadline_ts);
void atom_update(const int64_t current_ts, const double iops_scale, int64_t &deadline_ts);
void compare_and_update(const int64_t current_ts, const double iops_scale, int64_t &deadline_ts);
void reset();