Skip to content

Commit

Permalink
loadbalancer-experimental: assert a lock instead of comment about it (#…
Browse files Browse the repository at this point in the history
…2857)

Motivation:

An assert is worth a thousand comments.

Modifications:

Replace the comment about holding the lock in DefaultRequestTracker
with an assert.
  • Loading branch information
bryce-anderson authored Mar 1, 2024
1 parent ad90616 commit 2e6ca69
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ private static int applyPenalty(int currentEWMA, int currentLatency, long penalt
return (int) min(MAX_VALUE, max(currentEWMA, currentLatency) * penalty);
}

// must be called while holding the lock in write mode.
private void updateEwma(long penalty, long startTimeNanos) {
assert lock.isWriteLocked();
// We capture the current time while holding the lock to exploit the monotonic time source
// properties which prevent the time duration from going negative. This will result in a latency penalty
// as concurrency increases, but is a trade-off for simplicity.
Expand Down

0 comments on commit 2e6ca69

Please sign in to comment.