← Back to Pull requests

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

Open
unknown opened this pull request with 421 lines diff across 5 files
View on GitHub
unknown unknown commented on Sep 22, 2026 22:36 UTC
Author

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

<!--
_(If you are a project committer then you may remove some/all of the following template.)_

Before creating a pull request, please file an issue in the ASF Jira system for Solr:

https://issues.apache.org/jira/projects/SOLR

For something minor (i.e. that wouldn't be worth putting in release notes), you can skip JIRA.
To create a Jira issue, you will need to create an account there first.

The title of the PR should reference the Jira issue number in the form:

SOLR-####: <short description of problem or changes>

SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.

Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->

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:

  • [X] I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.

  • [X] I have created a Jira issue and added the issue ID to my pull request title.

  • [X] 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)

  • [X] I have developed this patch against the main branch.

  • [X] I have run ./gradlew check.

  • [X] I have added tests for my changes.

  • [X] I have added documentation for the Reference Guide

  • [X] I have added a changelog entry for my change
  • Diff: 421 lines (+315 / -106) across 5 files Reviewer: sigram Review duration: 91927m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.52) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 421 lines diff across 5 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    44%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.362
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4935"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 44.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 44.7% · Lower = rushed or shallow review
    44.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.8% · Safe to merge
    28.8%
    Repository