- For the priority, we need to consider a few basic rules:
- 1) if we just started requesting (delay is small), we should
- virtually always have a priority of zero.
- 2) for requests with average latency, our priority should match
- the average priority observed on the network
- 3) even the longest-running requests should not be WAY out of
- the observed average (thus we bound by a factor of 2)
- 4) we add +1 to the observed average priority to avoid everyone
- staying put at zero (2 * 0 = 0...).
-
- Using the specific calculation below, we get:
-
- delay = 0 => priority = 0;
- delay = avg delay => priority = running-average-observed-priority;
- delay >> avg_delay => priority = 2 * running-average-observed-priority;
-
- which satisfies all of the rules above.
-
- Note: M_PI_4 = PI/4 = arctan(1)
- */
- rp->priority = round ((GSF_current_priorities + 1.0) * atan (delay.rel_value / avg_delay)) / M_PI_4;
+ * For the priority, we need to consider a few basic rules:
+ * 1) if we just started requesting (delay is small), we should
+ * virtually always have a priority of zero.
+ * 2) for requests with average latency, our priority should match
+ * the average priority observed on the network
+ * 3) even the longest-running requests should not be WAY out of
+ * the observed average (thus we bound by a factor of 2)
+ * 4) we add +1 to the observed average priority to avoid everyone
+ * staying put at zero (2 * 0 = 0...).
+ *
+ * Using the specific calculation below, we get:
+ *
+ * delay = 0 => priority = 0;
+ * delay = avg delay => priority = running-average-observed-priority;
+ * delay >> avg_delay => priority = 2 * running-average-observed-priority;
+ *
+ * which satisfies all of the rules above.
+ *
+ * Note: M_PI_4 = PI/4 = arctan(1)
+ */
+ rp->priority =
+ round ((GSF_current_priorities +
+ 1.0) * atan (delay.rel_value_us / avg_delay)) / M_PI_4;