]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commit
Improve rate limiter implementation's readability (#8596)
authorhx235 <83968999+hx235@users.noreply.github.com>
Wed, 4 Aug 2021 17:42:49 +0000 (10:42 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 4 Aug 2021 17:43:47 +0000 (10:43 -0700)
commitdbe3810c74a0103919ccbcccee52feba7e652866
treeb284da859e8c9ef3686e2f8203cbf779582392dd
parent08af0ae3f0f3f69e8915f21fdca9659ed97ec847
Improve rate limiter implementation's readability (#8596)

Summary:
Context:
As need for new feature of resource management using RocksDB's rate limiter like [https://github.com/facebook/rocksdb/issues/8595](https://github.com/facebook/rocksdb/pull/8595) arises, it is about time to re-learn our rate limiter and make this learning process easier for others by improving its readability. The comment/assertion/one extra else-branch are added based on my best understanding toward the rate_limiter.cc and rate_limiter_test.cc up to date after giving it a hard read.
- Add code comments/assertion/one extra else-branch (that is not affecting existing behavior, see PR comment) to describe how leader-election works under multi-thread settings in GenericRateLimiter::Request()
- Add code comments to describe a non-obvious trick during clean-up of rate limiter destructor
- Add code comments to explain more about the starvation being fixed in GenericRateLimiter::Refill() through partial byte-granting
- Add code comments to the rate limiter's setup in a complicated unit test in rate_limiter_test

Pull Request resolved: https://github.com/facebook/rocksdb/pull/8596

Test Plan: - passed existing rate_limiter_test.cc

Reviewed By: ajkr

Differential Revision: D29982590

Pulled By: hx235

fbshipit-source-id: c3592986bb5b0c90d8229fe44f425251ec7e8a0a
util/rate_limiter.cc
util/rate_limiter.h
util/rate_limiter_test.cc