You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2021/02/08 20:41:29 UTC

[couchdb] branch fair-share-scheduler-3.x updated: [wip] add reference to original paper

This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch fair-share-scheduler-3.x
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/fair-share-scheduler-3.x by this push:
     new 28435b1  [wip] add reference to original paper
28435b1 is described below

commit 28435b1d62f27c6d6d52e5830b04ef6a96226130
Author: Nick Vatamaniuc <va...@apache.org>
AuthorDate: Mon Feb 8 15:41:15 2021 -0500

    [wip] add reference to original paper
---
 src/couch_replicator/src/couch_replicator.hrl      |  1 +
 .../src/couch_replicator_share.erl                 | 26 +++++++++++++++++-----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/src/couch_replicator/src/couch_replicator.hrl b/src/couch_replicator/src/couch_replicator.hrl
index b7670a9..e183493 100644
--- a/src/couch_replicator/src/couch_replicator.hrl
+++ b/src/couch_replicator/src/couch_replicator.hrl
@@ -49,6 +49,7 @@
 -type event() :: {Type:: event_type(), When :: erlang:timestamp()}.
 -type history() :: nonempty_list(event()).
 
+
 -record(job, {
     id :: job_id() | '$1' | '_',
     rep :: #rep{} | '_',
diff --git a/src/couch_replicator/src/couch_replicator_share.erl b/src/couch_replicator/src/couch_replicator_share.erl
index 2670b26..3c29023 100644
--- a/src/couch_replicator/src/couch_replicator_share.erl
+++ b/src/couch_replicator/src/couch_replicator_share.erl
@@ -10,6 +10,12 @@
 % License for the specific language governing permissions and limitations under
 % the License.
 
+% Algorithm implemented here is based on "A Fiar Share Scheduler" by Judy Kay
+% and Piers Lauder [1].
+%
+% [1] https://proteusmaster.urcf.drexel.edu/urcfwiki/images/KayLauderFairShare.pdf
+%
+
 -module(couch_replicator_share).
 
 -export([
@@ -140,18 +146,26 @@ charge_job(#job{} = Job, Interval, {_, _, _} = Now) ->
 
 
 priority_coeff() ->
+    % This is the K2 coefficient from [1]
     Default = ?DEFAULT_PRIORITY_COEFF,
-    StrVal = config:get("replicator", "priority_coeff", Default),
-    list_to_float(StrVal).
+    float_val(config:get("replicator", "priority_coeff", Default)).
 
 
 usage_coeff() ->
+    % This is the K1 coefficient from [1]
     Default = ?DEFAULT_USAGE_COEFF,
-    StrVal = config:get("replicator", "usage_coeff", Default),
-    list_to_float(StrVal).
+    float_val(config:get("replicator", "usage_coeff", Default)).
 
 
 min_usage() ->
     Default = ?DEFAULT_MIN_USAGE,
-    StrVal = config:get("replicator", "min_usage", Default),
-    list_to_float(StrVal).
+    float_val(config:get("replicator", "min_usage", Default)).
+
+
+float_val(Str) when is_list(Str) ->
+    try list_to_integer(Str) of
+        Int -> float(Int)
+    catch
+        error:badarg ->
+            list_to_float(Str)
+    end.