-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
change default ratelimiter high_resolution_clock to steady_clock #3328
change default ratelimiter high_resolution_clock to steady_clock #3328
Conversation
Hey @qqwangxiaow we'reok with this change, but looks like it doesnt compile
could you please update and verify the tests? also this scares me a little bit because this sounds like backwards incompatible changes, will dig into that a bit. |
tests need to be updated/more invesigation needs to be done to see if this is a backwards incompat change
@sbiscigl However, I recently discovered that the clock rollback might only cause rate limiting inaccuracies for a short period. |
…wangxiaow/aws-sdk-cpp into bug/fix-default-limiter-stuck-forever
Issue #, if available:
#806
#2949
Description of changes:
Implementation under the GCC C++20 version, std::chrono::high_resolution_clock is typically an alias for system_clock, which can lead to issues with clock rollback. The rate limiter relies on the time difference to replenish the local token bucket, and this could result in negative replenishment, causing the rate limiter to not function as expected and continuously sleep.
Although this is implemented as a template and allows for custom clock types, using steady_clock is a more reasonable choice for default users, as it is a monotonically increasing clock.
In Microsoft's MSVC compiler, high_resolution_clock is implemented as an alias for steady_clock.
GCC implemention:
https://github.com/gcc-mirror/gcc/blob/63663e4e69527b308687c63bacb0cc038b386593/libstdc%2B%2B-v3/include/bits/chrono.h#L1285
MSVC:
https://github.com/hsutter/STL/blob/c53ac59abae552e50654943f7f80f23376a8039a/stl/inc/__msvc_chrono.hpp#L814
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.