gavinchou commented on code in PR #38294: URL: https://github.com/apache/doris/pull/38294#discussion_r1695354419
########## common/cpp/s3_rate_limiter.cpp: ########## @@ -69,29 +70,31 @@ S3RateLimiter::~S3RateLimiter() = default; S3RateLimiterHolder::~S3RateLimiterHolder() = default; -std::pair<size_t, double> S3RateLimiter::_update_remain_token( - std::chrono::system_clock::time_point now, size_t amount) { +std::pair<size_t, double> S3RateLimiter::_update_remain_token(long now, size_t amount) { // Values obtained under lock to be checked after release size_t count_value; double tokens_value; { std::lock_guard<SimpleSpinLock> lock(*_mutex); if (_max_speed) { - double delta_seconds = static_cast<double>((now - _prev_ms).count()) / MS; + double delta_seconds = + _prev_ns_count ? static_cast<double>(now - _prev_ns_count) / NS : 0; _remain_tokens = std::min<double>(_remain_tokens + _max_speed * delta_seconds - amount, _max_burst); } _count += amount; count_value = _count; tokens_value = _remain_tokens; - _prev_ms = now; + _prev_ns_count = now; } return {count_value, tokens_value}; } int64_t S3RateLimiter::add(size_t amount) { // Values obtained under lock to be checked after release - auto [count_value, tokens_value] = _update_remain_token(CURRENT_TIME, amount); + auto time = CURRENT_TIME; + auto [count_value, tokens_value] = + _update_remain_token(time.time_since_epoch().count(), amount); Review Comment: explicit duration cast as nano -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org