Skip to content

SOLR-18476: Support file suffix based MMapDirectory preload - #4935

Open
liangkaiwen wants to merge 2 commits into
apache:mainfrom
liangkaiwen:jira/SOLR-18476
Open

liangkaiwen wants to merge 2 commits into
apache:mainfrom
liangkaiwen:jira/SOLR-18476

Conversation

@liangkaiwen

@liangkaiwen liangkaiwen commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-18476

Description

Existing usage of preload=true will attempt to load the entire index (filesystem) directory into OS page cache indiscriminately. This can be a problematic take on a good idea in 2 ways: 1) you may not want to run this long synchronous preload over the entire index and 2) you may not have enough physical memory to fit the whole index, so having the ability to prioritize some index files over others would be more practical/useful.

Solution

Coded using Claude 5.0 Opus

  • Added "preloadExtensions" to StandardDirectoryFactory config definition (and all implementing classes like NRTCachingDirectoryFactory / MMapDirectoryFactory), which allows a comma separate list of file extensions to be provided (does not need to be used in conjunction with preload=true)
    • This also fixes an existing bug where preload=true was not respected at all by NRTCachingDirectoryFactory
  • StandardDirectoryFactory's create function uses a preload predicate depending on the configuration. Extensions predicate matches files with extension (after last "." in the filename) matching any of the provided in the configuration
  • Extensions provided are matched case-insensitively and "." is not required. Ordering of the extensions provided has no bearing on behavior
  • When preload=true is provided and preloadExtensions is provided, preloadExtensions behavior will take precedence (whole index not preloaded)

Tests

  • Add unit tests for MMapDirectoryFactory
  • Check OS off-heap memory metrics

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide
  • I have added a changelog entry for my change

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests labels Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant