Skip to content

Add cfs options - #1050

Open
aprudhomme wants to merge 8 commits into
mainfrom
add_cfs_options
Open

aprudhomme wants to merge 8 commits into
mainfrom
add_cfs_options

Conversation

@aprudhomme

Copy link
Copy Markdown
Contributor

Summary

Adds settings for Lucene's compound file (.cfs) behavior. Until now nrtsearch always used Lucene's defaults. These settings let you change when segments are written as compound files, or turn compound files off.

New settings

Setting Type Default Lucene API
useCompoundFile Index setting true IndexWriterConfig.setUseCompoundFile
noCFSRatio Index live setting 0.1 MergePolicy.setNoCFSRatio
maxCFSSegmentSizeMB Index live setting 0 (no limit) MergePolicy.setMaxCFSSegmentSizeMB
  • useCompoundFile applies to newly flushed segments.
  • noCFSRatio and maxCFSSegmentSizeMB apply to merged segments. A merged segment is written as a compound file only if it is no larger than noCFSRatio × total index size and no larger than maxCFSSegmentSizeMB.
  • To turn compound files off completely, set useCompoundFile: false and noCFSRatio: 0.0.
  • The defaults match Lucene's current behavior, so existing indices are unchanged.
  • Like the other merge policy live settings, changes to noCFSRatio and maxCFSSegmentSizeMB take effect the next time the index writer is opened.

Changes

  • luceneserver.proto: added IndexSettings.useCompoundFile (field 9), plus IndexLiveSettings.noCFSRatio (20) and IndexLiveSettings.maxCFSSegmentSizeMB (21)
  • ImmutableIndexState / IndexState: added defaults, validation (noCFSRatio in [0.0, 1.0], maxCFSSegmentSizeMB >= 0), getters, and applied in getIndexWriterConfig()
  • liveSettingsV2 CLI: added --noCFSRatio and --maxCFSSegmentSizeMB
  • Docs: index_settings.rst, index_live_settings.rst

Testing

  • New unit tests in ImmutableIndexStateTest cover defaults, set values, validation, and that values reach the IndexWriterConfig / merge policy
  • Updated StateBackendServerTest for the new default fields

…ettingsV2

Add two new options to LiveSettingsV2Command to expose Lucene compound-file
(CFS) settings:
- --noCFSRatio: Fraction of total merged index size below which segments use CFS
- --maxCFSSegmentSizeMB: Maximum segment size in MB to use CFS (0 = unlimited)

Both settings follow the existing pattern for Double option fields and null
checks in the call() method.
Use TieredMergePolicy's default noCFSRatio (0.1) so existing indices keep
their current behavior. Document that useCompoundFile only applies to
flushed segments, while noCFSRatio/maxCFSSegmentSizeMB control merged ones.
@aprudhomme
aprudhomme requested a review from sarthakn7 October 12, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant