Skip to content

Conversation

shubhamsrkdev
Copy link
Contributor

@shubhamsrkdev shubhamsrkdev commented Oct 7, 2025

Problem

Lucene uses CFS ratio (which is by default 10%) to determine whether to use Compound Files.

Solution

In this PR we are doing the following:

  • Switching from a CFS ratio to a fixed threshold which is:

    • 64MB for byte-size-based merge policies
    • 65,536 docs for doc-based merge policies
  • Moved CFS configuration to CompoundFormat.java from Merge policies.

Fixes #14959

@shubhamsrkdev shubhamsrkdev marked this pull request as ready for review October 7, 2025 14:28
}

// Apply appropriate threshold based on merge policy type
if (mergePolicy instanceof LogDocMergePolicy) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we can avoid customizing it for specific policies, otherwise it might be tricky to maintain in the future, if e.g. there is another policy that is based on doc size not bytes.

Maybe we can add a enum and a method to MergePolicy which returns its unit (bytes/docs) , and use it here to decide which threshold to use?

Or do we want to always choose compound format based on size in bytes even for LogDocMergePolicy? In this case we might be able to use merge.getMergeInfo().sizeInBytes() when we call this method and avoid relying on MergePolicy#size all together?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to the idea of Enums, I will wait if anyone else has other suggestions here but having an enum makes most sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to a fixed CFS threshold

2 participants