You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/05/18 11:30:26 UTC
[GitHub] [lucene] jpountz opened a new pull request, #900: LUCENE-10574: Prevent pathological merging.
jpountz opened a new pull request, #900:
URL: https://github.com/apache/lucene/pull/900
This updates TieredMergePolicy and Log(Doc|Size)MergePolicy to only ever
consider merges where the resulting segment would be at least 50% bigger than
the biggest input segment. While a merge that only grows the biggest segment by
50% is still quite inefficient, this constraint is good enough to prevent
pathological O(N^2) merging.
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] jpountz commented on a diff in pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
jpountz commented on code in PR #900:
URL: https://github.com/apache/lucene/pull/900#discussion_r875876270
##########
lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java:
##########
@@ -532,13 +532,21 @@ private MergeSpecification doFindMerges(
// segments, and already pre-excluded the too-large segments:
assert candidate.size() > 0;
+ SegmentSizeAndDocs maxSegmentSize = segInfosSizes.get(candidate.get(0));
+ if (hitTooLarge == false
+ && mergeType == MERGE_TYPE.NATURAL
+ && bytesThisMerge < maxSegmentSize.sizeInBytes * 1.5) {
+ // Ignore any merge where the resulting segment is not at least 50% larger than the
Review Comment:
I added javadocs to SegmentSizeAndDocs
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] jpountz commented on a diff in pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
jpountz commented on code in PR #900:
URL: https://github.com/apache/lucene/pull/900#discussion_r875848606
##########
lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java:
##########
@@ -582,23 +589,29 @@ public MergeSpecification findMerges(
if (anyMerging) {
// skip
} else if (!anyTooLarge) {
- if (spec == null) spec = new MergeSpecification();
- final List<SegmentCommitInfo> mergeInfos = new ArrayList<>(end - start);
- for (int i = start; i < end; i++) {
- mergeInfos.add(levels.get(i).info);
- assert infos.contains(levels.get(i).info);
- }
- if (verbose(mergeContext)) {
- message(
- " add merge="
- + segString(mergeContext, mergeInfos)
- + " start="
- + start
- + " end="
- + end,
- mergeContext);
- }
- spec.add(new OneMerge(mergeInfos));
+ if (mergeSize >= maxSegmentSize * 1.5) {
+ // Ignore any merge where the resulting segment is not at least 50% larger than the
+ // biggest input segment.
+ // Otherwise we could run into pathological O(N^2) merging where merges keep rewriting
+ // again and again the biggest input segment into a segment that is barely bigger.
+ if (spec == null) spec = new MergeSpecification();
Review Comment:
It's not spotless, it's just because I didn't touch this line of code, only changed indentation.
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] dweiss commented on a diff in pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
dweiss commented on code in PR #900:
URL: https://github.com/apache/lucene/pull/900#discussion_r875895539
##########
lucene/core/src/test/org/apache/lucene/index/TestIndexWriterMergePolicy.java:
##########
@@ -310,22 +365,18 @@ private void checkInvariants(IndexWriter writer) throws IOException {
if (docCount <= upperBound) {
numSegments++;
} else {
- if (upperBound * mergeFactor <= maxMergeDocs) {
- assertTrue(
- "maxMergeDocs="
- + maxMergeDocs
- + "; numSegments="
- + numSegments
- + "; upperBound="
- + upperBound
- + "; mergeFactor="
- + mergeFactor
- + "; segs="
- + writer.segString()
- + " config="
- + writer.getConfig(),
- numSegments < mergeFactor);
- }
+ assertTrue(
Review Comment:
I know this isn't related to the change, but perhaps worth fixing when you see it - these concatenations can be nicely indented by adding parentheses around logical parts. Then spotless takes care of wrapping them up in nicer blocks.
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on a diff in pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
mikemccand commented on code in PR #900:
URL: https://github.com/apache/lucene/pull/900#discussion_r875839832
##########
lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java:
##########
@@ -532,13 +532,21 @@ private MergeSpecification doFindMerges(
// segments, and already pre-excluded the too-large segments:
assert candidate.size() > 0;
+ SegmentSizeAndDocs maxSegmentSize = segInfosSizes.get(candidate.get(0));
Review Comment:
The incoming (sorted) infos are sorted by decreasing size, right? So the `candidate.get(0)` is indeed the max.
Maybe rename to `maxCadidateSegmentSize`?
##########
lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java:
##########
@@ -532,13 +532,21 @@ private MergeSpecification doFindMerges(
// segments, and already pre-excluded the too-large segments:
assert candidate.size() > 0;
+ SegmentSizeAndDocs maxSegmentSize = segInfosSizes.get(candidate.get(0));
+ if (hitTooLarge == false
+ && mergeType == MERGE_TYPE.NATURAL
+ && bytesThisMerge < maxSegmentSize.sizeInBytes * 1.5) {
+ // Ignore any merge where the resulting segment is not at least 50% larger than the
Review Comment:
Hmm so this new logic applies to all merges, not just the "under floor" ones? I wonder if there is some risk here that this change will block "pathological" merges that we intentionally do today under heavy deletions count cases? Maybe we should pro-rate by deletion percent? Oh! I think `SegmentSizeAndDocs` already does so (well the `size` method in `MergePolicy`). Maybe we should add a comment / javadoc in this confusing class heh.
##########
lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java:
##########
@@ -582,23 +589,29 @@ public MergeSpecification findMerges(
if (anyMerging) {
// skip
} else if (!anyTooLarge) {
- if (spec == null) spec = new MergeSpecification();
- final List<SegmentCommitInfo> mergeInfos = new ArrayList<>(end - start);
- for (int i = start; i < end; i++) {
- mergeInfos.add(levels.get(i).info);
- assert infos.contains(levels.get(i).info);
- }
- if (verbose(mergeContext)) {
- message(
- " add merge="
- + segString(mergeContext, mergeInfos)
- + " start="
- + start
- + " end="
- + end,
- mergeContext);
- }
- spec.add(new OneMerge(mergeInfos));
+ if (mergeSize >= maxSegmentSize * 1.5) {
+ // Ignore any merge where the resulting segment is not at least 50% larger than the
+ // biggest input segment.
+ // Otherwise we could run into pathological O(N^2) merging where merges keep rewriting
+ // again and again the biggest input segment into a segment that is barely bigger.
+ if (spec == null) spec = new MergeSpecification();
Review Comment:
Hmm, split this into multiple lines with { and }? Does spotless/tidy do that?
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] dweiss commented on a diff in pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
dweiss commented on code in PR #900:
URL: https://github.com/apache/lucene/pull/900#discussion_r875894329
##########
lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java:
##########
@@ -582,23 +589,29 @@ public MergeSpecification findMerges(
if (anyMerging) {
// skip
} else if (!anyTooLarge) {
- if (spec == null) spec = new MergeSpecification();
- final List<SegmentCommitInfo> mergeInfos = new ArrayList<>(end - start);
- for (int i = start; i < end; i++) {
- mergeInfos.add(levels.get(i).info);
- assert infos.contains(levels.get(i).info);
- }
- if (verbose(mergeContext)) {
- message(
- " add merge="
- + segString(mergeContext, mergeInfos)
- + " start="
- + start
- + " end="
- + end,
- mergeContext);
- }
- spec.add(new OneMerge(mergeInfos));
+ if (mergeSize >= maxSegmentSize * 1.5) {
+ // Ignore any merge where the resulting segment is not at least 50% larger than the
+ // biggest input segment.
+ // Otherwise we could run into pathological O(N^2) merging where merges keep rewriting
+ // again and again the biggest input segment into a segment that is barely bigger.
+ if (spec == null) spec = new MergeSpecification();
Review Comment:
spotless doesn't add code (add brackets, etc.) - it merely rewraps existing code.
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] jpountz merged pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
jpountz merged PR #900:
URL: https://github.com/apache/lucene/pull/900
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] rmuir commented on a diff in pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
rmuir commented on code in PR #900:
URL: https://github.com/apache/lucene/pull/900#discussion_r875797459
##########
lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCase.java:
##########
@@ -1009,69 +1007,6 @@ protected synchronized boolean maybeStall(MergeSource mergeSource) {
return c;
}
- private static void avoidPathologicalMerging(IndexWriterConfig iwc) {
Review Comment:
this is good
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on a diff in pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
mikemccand commented on code in PR #900:
URL: https://github.com/apache/lucene/pull/900#discussion_r875924090
##########
lucene/core/src/java/org/apache/lucene/index/LogMergePolicy.java:
##########
@@ -582,23 +589,29 @@ public MergeSpecification findMerges(
if (anyMerging) {
// skip
} else if (!anyTooLarge) {
- if (spec == null) spec = new MergeSpecification();
- final List<SegmentCommitInfo> mergeInfos = new ArrayList<>(end - start);
- for (int i = start; i < end; i++) {
- mergeInfos.add(levels.get(i).info);
- assert infos.contains(levels.get(i).info);
- }
- if (verbose(mergeContext)) {
- message(
- " add merge="
- + segString(mergeContext, mergeInfos)
- + " start="
- + start
- + " end="
- + end,
- mergeContext);
- }
- spec.add(new OneMerge(mergeInfos));
+ if (mergeSize >= maxSegmentSize * 1.5) {
+ // Ignore any merge where the resulting segment is not at least 50% larger than the
+ // biggest input segment.
+ // Otherwise we could run into pathological O(N^2) merging where merges keep rewriting
+ // again and again the biggest input segment into a segment that is barely bigger.
+ if (spec == null) spec = new MergeSpecification();
Review Comment:
Oh I see! OK, thanks for explaining.
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mikemccand commented on a diff in pull request #900: LUCENE-10574: Prevent pathological merging.
Posted by GitBox <gi...@apache.org>.
mikemccand commented on code in PR #900:
URL: https://github.com/apache/lucene/pull/900#discussion_r875923145
##########
lucene/core/src/java/org/apache/lucene/index/TieredMergePolicy.java:
##########
@@ -532,13 +532,21 @@ private MergeSpecification doFindMerges(
// segments, and already pre-excluded the too-large segments:
assert candidate.size() > 0;
+ SegmentSizeAndDocs maxSegmentSize = segInfosSizes.get(candidate.get(0));
+ if (hitTooLarge == false
+ && mergeType == MERGE_TYPE.NATURAL
+ && bytesThisMerge < maxSegmentSize.sizeInBytes * 1.5) {
+ // Ignore any merge where the resulting segment is not at least 50% larger than the
Review Comment:
Thanks @jpountz!
--
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-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org