[ https://issues.apache.org/jira/browse/LUCENE-10448?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
kkewwei updated LUCENE-10448: ----------------------------- Description: We can see the code in *MergeRateLimiter*: {code:java} private long maybePause(long bytes, long curNS) throws MergePolicy.MergeAbortedException { double rate = mbPerSec; double secondsToPause = (bytes / 1024. / 1024.) / rate; 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; return -1; } ...... } {code} If a Segment is been merged, *maybePause* is called in 7:00, lastNS=7:00, then the *maybePause* is called in 7:05, so the value of *targetNS=lastNS + (long) (1000000000 * secondsToPause)* must smaller than *curNS*, so we will return -1. As long as the interval between two *maybePause* calls is relatively long, the pause that should be executed will not be executed. was: We can see the code: {code:java} private long maybePause(long bytes, long curNS) throws MergePolicy.MergeAbortedException { double rate = mbPerSec; double secondsToPause = (bytes / 1024. / 1024.) / rate; 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; return -1; } ...... } {code} If a Segment is been merged, `maybePause` is called in `7:00`, lastNS=7:00, then the `maybePause` is called in `7:05`, so the value of `targetNS=lastNS + (long) (1000000000 * secondsToPause)` must smaller than `curNS`, so we will return -1. As long as the interval between two `maybePause` calls is relatively long, the pause that should be executed will not be executed. > MergeRateLimiter doesn't always limit instant rate. > --------------------------------------------------- > > Key: LUCENE-10448 > URL: https://issues.apache.org/jira/browse/LUCENE-10448 > Project: Lucene - Core > Issue Type: Bug > Components: core/other > Affects Versions: 8.11.1 > Reporter: kkewwei > Priority: Major > > We can see the code in *MergeRateLimiter*: > {code:java} > private long maybePause(long bytes, long curNS) throws > MergePolicy.MergeAbortedException { > > double rate = mbPerSec; > double secondsToPause = (bytes / 1024. / 1024.) / rate; > 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; > return -1; > } > ...... > } > {code} > If a Segment is been merged, *maybePause* is called in 7:00, lastNS=7:00, > then the *maybePause* is called in 7:05, so the value of *targetNS=lastNS + > (long) (1000000000 * secondsToPause)* must smaller than *curNS*, so we will > return -1. As long as the interval between two *maybePause* calls is > relatively long, the pause that should be executed will not be executed. > -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org