benwtrent commented on code in PR #13190: URL: https://github.com/apache/lucene/pull/13190#discussion_r1531018293
########## lucene/core/src/java/org/apache/lucene/index/MergeRateLimiter.java: ########## @@ -118,24 +118,32 @@ private long maybePause(long bytes, long curNS) throws MergePolicy.MergeAbortedE throw new MergePolicy.MergeAbortedException("Merge aborted."); } - double rate = mbPerSec; // read from volatile rate once. - double secondsToPause = (bytes / 1024. / 1024.) / rate; - - // Time we should sleep until; this is purely instantaneous - // rate (just adds seconds onto the last time we had paused to); - // maybe we should also offer decayed recent history one? - long targetNS = lastNS + (long) (1000000000 * secondsToPause); - - long curPauseNS = targetNS - curNS; - - // We don't bother with thread pausing if the pause is smaller than 2 msec. - if (curPauseNS <= MIN_PAUSE_NS) { - // Set to curNS, not targetNS, to enforce the instant rate, not - // the "averaged over all history" rate: - lastNS = curNS; + final double rate = mbPerSec; // read from volatile rate once. + final double secondsToPause = (bytes / 1024. / 1024.) / rate; + + AtomicLong curPauseNSSetter = new AtomicLong(); + lastNS.updateAndGet( Review Comment: So, the limits are on a per `RateLimitedIndexOutput` bases, not necessarily per thread. Since all `RateLimitedIndexOutput` constructed share the same rate-limiter, it might pause all threads? But I don't think so, as each process could have its own `RateLimitedIndexOutput` which is tracking its own bytes locally and while the combined total of all threads might exceed the throttling limit, the output isn't really throttled until a single thread exceeds the limit. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org