summaryrefslogtreecommitdiffstats
path: root/xlators/features/bit-rot/src/bitd/bit-rot.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2016-07-01 15:54:07 +0530
committerJeff Darcy <jdarcy@redhat.com>2016-07-19 06:14:13 -0700
commit2526f9d3ddc3e7f62828ac4289001b22638ae42a (patch)
tree7bd7a766098f2ce8d08583647b85c778ccf8505c /xlators/features/bit-rot/src/bitd/bit-rot.c
parent74d2aaf51c7ff601e4394cad9f8e23092267af55 (diff)
features/bitrot: Move throttling code to libglusterfs
Backport of http://review.gluster.org/14846 Since throttling is a separate feature by itself, move throttling code to libglusterfs. Change-Id: If9b99885ceb46e5b1865a4af18b2a2caecf59972 BUG: 1357514 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: http://review.gluster.org/14944 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/features/bit-rot/src/bitd/bit-rot.c')
-rw-r--r--xlators/features/bit-rot/src/bitd/bit-rot.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/xlators/features/bit-rot/src/bitd/bit-rot.c b/xlators/features/bit-rot/src/bitd/bit-rot.c
index 46bef085404..99a28672501 100644
--- a/xlators/features/bit-rot/src/bitd/bit-rot.c
+++ b/xlators/features/bit-rot/src/bitd/bit-rot.c
@@ -283,7 +283,7 @@ br_object_read_block_and_sign (xlator_t *this, fd_t *fd, br_child_t *child,
off_t offset, size_t size, SHA256_CTX *sha256)
{
int32_t ret = -1;
- br_tbf_t *tbf = NULL;
+ tbf_t *tbf = NULL;
struct iovec *iovec = NULL;
struct iobref *iobref = NULL;
br_private_t *priv = NULL;
@@ -316,12 +316,12 @@ br_object_read_block_and_sign (xlator_t *this, fd_t *fd, br_child_t *child,
goto out;
for (i = 0; i < count; i++) {
- TBF_THROTTLE_BEGIN (tbf, BR_TBF_OP_HASH, iovec[i].iov_len);
+ TBF_THROTTLE_BEGIN (tbf, TBF_OP_HASH, iovec[i].iov_len);
{
SHA256_Update (sha256, (const unsigned char *)
(iovec[i].iov_base), iovec[i].iov_len);
}
- TBF_THROTTLE_BEGIN (tbf, BR_TBF_OP_HASH, iovec[i].iov_len);
+ TBF_THROTTLE_BEGIN (tbf, TBF_OP_HASH, iovec[i].iov_len);
}
out:
@@ -1760,14 +1760,32 @@ static int32_t
br_rate_limit_signer (xlator_t *this, int child_count, int numbricks)
{
br_private_t *priv = NULL;
- br_tbf_opspec_t spec = {0,};
+ tbf_opspec_t spec = {0,};
priv = this->private;
- spec.op = BR_TBF_OP_HASH;
+ spec.op = TBF_OP_HASH;
spec.rate = 0;
spec.maxlimit = 0;
+/**
+ * OK. Most implementations of TBF I've come across generate tokens
+ * every second (UML, etc..) and some chose sub-second granularity
+ * (blk-iothrottle cgroups). TBF algorithm itself does not enforce
+ * any logic for choosing generation interval and it seems pretty
+ * logical as one could jack up token count per interval w.r.t.
+ * generation rate.
+ *
+ * Value used here is chosen based on a series of test(s) performed
+ * to balance object signing time and not maxing out on all available
+ * CPU cores. It's obvious to have seconds granularity and jack up
+ * token count per interval, thereby achieving close to similar
+ * results. Let's stick to this as it seems to be working fine for
+ * the set of ops that are throttled.
+ **/
+ spec.token_gen_interval = 600000; /* In usec */
+
+
#ifdef BR_RATE_LIMIT_SIGNER
double contribution = 0;
@@ -1787,7 +1805,7 @@ br_rate_limit_signer (xlator_t *this, int child_count, int numbricks)
"[Rate Limit Info] \"tokens/sec (rate): %lu, "
"maxlimit: %lu\"", spec.rate, spec.maxlimit);
- priv->tbf = br_tbf_init (&spec, 1);
+ priv->tbf = tbf_init (&spec, 1);
return priv->tbf ? 0 : -1;
}