diff options
author | Venky Shankar <vshankar@redhat.com> | 2015-04-17 15:00:13 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-05-07 07:14:32 -0700 |
commit | 4c6e9c5f8d62444412c86545868cdb5bf6a06b39 (patch) | |
tree | 524afb5cd7058e3d8ce071258a70e18ca269b9a8 /xlators/features/bit-rot/src/bitd/bit-rot.h | |
parent | aa938247e19afa419476fb2d0b7cb2d054c6dd47 (diff) |
features/bit-rot: Token Bucket based throttling
BitRot daemons (signer & scrubber) are disk/cpu hoggers when left
running full throttle. Checksum calculations (especially SHA family
of hash routines) can be quite CPU intensive. Moreover periodic
disk scans performed by scrubber followed by reading data blocks
for hash calculation (which is also done by signer) generate lot
of heavy IO request(s). This causes interference with actual client
operations (be it a regular client or filesystems daemons such as
self-heal, etc..) and results in degraded system performance.
This patch introduces throttling based on Token Bucket Filtering[1].
It's a well known algorithm for checking (and ensuring) that data
transmission conform to defined limits and generally used in packet
switched networks. Linux control groups (Cgroups) uses a variant[2]
of this algorithm to provide block device IO throttling (cgroup
subsys "blkio": blk-iothrottle).
So, why not just live with Cgroups?
Cgroups is linux specific. We need to have a throttling mechanism
for other supported UNIXes. Moreover, having our own implementation
gives much more finer control in terms of tuning it for our needs
(plus the simplicity of the alogorithm itself).
Ideally, throttling should be a part of server stack (either as a
separate translator or integrated with io-threads) since that's
the point of entry for IO request(s) from *all* client(s). That
way one could selectively throttle IO request(s) based on client
PIDs (frame->root->pid), e.g., self-heal daemon, bitrot, etc..
(*actual* clients can run full throttle). This implementation
avoids that deliberately (there needs to be a much more smarter
queueing mechanism) and throttles CPU usage for hash calculations.
This patch is just the infrastructure part with no interfaces
exposed to set various throttling values. The tunable selected
here (basically hardcoded) avoids 100% CPU usage during hash
calculation (with some bursts cycles). We'd need much more
intensive test(s) to assign values for various throttling
options (lazy/normal/aggressive).
[1] https://en.wikipedia.org/wiki/Token_bucket
[2] http://en.wikipedia.org/wiki/Token_bucket#Hierarchical_token_bucket
Change-Id: Icc49af80eeab6adb60166d0810e69ef37cfe2fd8
BUG: 1207020
Signed-off-by: Venky Shankar <vshankar@redhat.com>
Reviewed-on: http://review.gluster.org/10307
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features/bit-rot/src/bitd/bit-rot.h')
-rw-r--r-- | xlators/features/bit-rot/src/bitd/bit-rot.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.h b/xlators/features/bit-rot/src/bitd/bit-rot.h index a634a1fa76f..5b641801916 100644 --- a/xlators/features/bit-rot/src/bitd/bit-rot.h +++ b/xlators/features/bit-rot/src/bitd/bit-rot.h @@ -25,13 +25,18 @@ #include "changelog.h" #include "timer-wheel.h" +#include "bit-rot-tbf.h" + #include "bit-rot-common.h" #include "bit-rot-stub-mem-types.h" #include <openssl/sha.h> -/* TODO: make this configurable */ -#define BR_WORKERS 8 +/** + * TODO: make this configurable. As a best practice, set this to the + * number of processor cores. + */ +#define BR_WORKERS 4 #define signature_size(hl) (sizeof (br_isignature_t) + hl + 1) @@ -92,6 +97,8 @@ struct br_private { the objects */ int32_t expiry_time; /* objects "wait" time */ + br_tbf_t *tbf; /* token bucket filter */ + gf_boolean_t iamscrubber; /* function as a fs scrubber */ }; |