Skip to content

Conversation

@x-INFiN1TY-x
Copy link
Contributor

@x-INFiN1TY-x x-INFiN1TY-x commented Oct 16, 2025

Summary

This CR enhances the OpenSearch /_nodes/stats/file_cache API by adding comprehensive cache monitoring capabilities and fixes a critical JSON field-name collision that caused nested used_in_bytes to be reported as 0.

  • miss_count field: Extends cache miss tracking to all nested statistics objects (previously only available at root level)
  • removed_in_bytes / removed (human-readable): Adds explicit removal tracking to distinguish operational removals from capacity-driven evictions
  • Bug fix: Introduce PINNED_IN_BYTES and stop writing pinned usage to USED_IN_BYTES (removes field-name collision so nested used_in_bytes now report actual usage)

API Response Enhancement

Before (Incomplete Visibility):

{
  "_nodes": {"total": 1, "successful": 1, "failed": 0},
  "cluster_name": "REDACTED:REDACTED-REDACTED",
  "nodes": {
    "_-REDACTED": {
      "aggregate_file_cache": {
        "active_in_bytes": 0,
        "total_in_bytes": 368353338982,
        "used_in_bytes": 0,
        "pinned_in_bytes": 0,
        "evictions_in_bytes": 0,
        "hit_count": 1008237,
        "miss_count": 904846,              // Only at ROOT level

        "over_all_stats": {
          "active_in_bytes": 0,
          "used_in_bytes": 0,              
          "evictions_in_bytes": 0,
          "hit_count": 1008237
          // ❌ MISSING: miss_count
          // ❌ MISSING: removed_in_bytes
        },
        "full_file_stats": {
          "active_in_bytes": 0,
          "used_in_bytes": 0,
          "evictions_in_bytes": 0,
          "hit_count": 69
          // ❌ MISSING: miss_count
          // ❌ MISSING: removed_in_bytes
        },
        "block_file_stats": {
          "active_in_bytes": 0,
          "used_in_bytes": 0,
          "evictions_in_bytes": 0,
          "hit_count": 1008168
          // ❌ MISSING: miss_count
          // ❌ MISSING: removed_in_bytes
        },
        "pinned_file_stats": {
          "active_in_bytes": 0,
          "used_in_bytes": 0,
          "evictions_in_bytes": 0,
          "hit_count": 0
          // ❌ MISSING: miss_count
          // ❌ MISSING: removed_in_bytes
        }
      }
    }
  }
}

After:

{
  "_nodes": {"total": 1, "successful": 1, "failed": 0},
  "cluster_name": "REDACTED:REDACTED-REDACTED",
  "nodes": {
    "REDACTED": {
      "aggregate_file_cache": {
        "active_in_bytes": 0,
        "active": "0b",
        "total_in_bytes": 368353338982,
        "total": "343.2gb",
        "used_in_bytes": 0,
        "used": "0b",
        "pinned_in_bytes": 0,
        "pinned": "0b",
        "evictions_in_bytes": 0,
        "evictions": "0b",
        "removed_in_bytes": 67890,         // NEW: Total explicit removals
        "removed": "66.3kb",               // NEW: Human readable
        "hit_count": 1008237,
        "miss_count": 904846,

        "over_all_stats": {
          "active_in_bytes": 0,
          "active": "0b",
          "used_in_bytes": 382533541,      
          "used": "364.9mb",
          "evictions_in_bytes": 0,
          "evictions": "0b",
          "removed_in_bytes": 67890,       // NEW: Overall removals
          "removed": "66.3kb",
          "active_percent": 0,
          "hit_count": 1008237,
          "miss_count": 904846             // NEW: Overall miss count
        },
        "full_file_stats": {
          "active_in_bytes": 0,
          "active": "0b",
          "used_in_bytes": 41445300,       
          "used": "39.5mb",
          "evictions_in_bytes": 0,
          "evictions": "0b",
          "removed_in_bytes": 22212,       // NEW
          "removed": "21.7kb",
          "active_percent": 0,
          "hit_count": 69,
          "miss_count": 0                  // NEW
        },
        "block_file_stats": {
          "active_in_bytes": 0,
          "active": "0b",
          "used_in_bytes": 341088241,      
          "used": "325.2mb",
          "evictions_in_bytes": 0,
          "evictions": "0b",
          "removed_in_bytes": 45678,       // NEW
          "removed": "44.6kb",
          "active_percent": 0,
          "hit_count": 1008168,
          "miss_count": 904846             // NEW
        },
        "pinned_file_stats": {
          "active_in_bytes": 0,
          "active": "0b",
          "used_in_bytes": 0,
          "used": "0b",
          "evictions_in_bytes": 0,
          "evictions": "0b",
          "removed_in_bytes": 0,           // NEW
          "removed": "0b",
          "active_percent": 0,
          "hit_count": 0,
          "miss_count": 0                  // NEW
        }
      }
    }
  }
}

@github-actions
Copy link
Contributor

❌ Gradle check result for 5fc979c: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@x-INFiN1TY-x x-INFiN1TY-x changed the title Enhance /_nodes/stats/file_cache API with miss_count and removed_in_bytes fields Add miss_count and removed_in_bytes fields in /_nodes/stats/file_cache API Oct 16, 2025
@x-INFiN1TY-x x-INFiN1TY-x changed the title Add miss_count and removed_in_bytes fields in /_nodes/stats/file_cache API Add miss_count and removed_in_bytes fields in /_nodes/stats/file_cache API and fix used_in_bytes field collision Oct 16, 2025
@github-actions
Copy link
Contributor

❌ Gradle check result for 658c9a5: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

@Gagan6164 Gagan6164 left a comment

Choose a reason for hiding this comment

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

Changes looks good to me.

@x-INFiN1TY-x x-INFiN1TY-x force-pushed the EnhanceNodesStatsFileCacheAPI branch from 658c9a5 to 2c1bef7 Compare October 17, 2025 12:51
@github-actions
Copy link
Contributor

❌ Gradle check result for 2c1bef7: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

❌ Gradle check result for 42c9c8f: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@opensearch-trigger-bot
Copy link
Contributor

This PR is stalled because it has been open for 30 days with no activity.

@opensearch-trigger-bot opensearch-trigger-bot bot added the stalled Issues that have stalled label Nov 20, 2025
@gbbafna
Copy link
Contributor

gbbafna commented Nov 24, 2025

@x-INFiN1TY-x : can you rebase this please ?

…s fields

Add cache miss tracking and explicit removal tracking to file cache statistics:

Add miss_count field to all nested statistics objects for hit ratio analysis
Add removed_in_bytes field to distinguish manual removals from automatic evictions
Update FileCacheStats with getRemoved() method and enhanced JSON serialization
Update AggregateFileCacheStats with aggregate JSON serialization for new fields
Update FileCache fileCacheStats() method to pass removal data
Add comprehensive test coverage including MissCountValidationTest
Update all FileCacheStats constructor calls to include removed parameter
Enables hit ratio calculation, cache pressure monitoring, and performance debugging
across different file types in the cache hierarchy.

Signed-off-by: tanishq ranjan <[email protected]>
Signed-off-by: tanishq ranjan <[email protected]>
Signed-off-by: tanishq ranjan <[email protected]>
Signed-off-by: tanishq ranjan <[email protected]>
@x-INFiN1TY-x x-INFiN1TY-x force-pushed the EnhanceNodesStatsFileCacheAPI branch from 42c9c8f to 9820c2c Compare November 24, 2025 10:01
@x-INFiN1TY-x
Copy link
Contributor Author

@gbbafna Done!

All FileCacheStats constructor signature issues have been resolved:
- Fixed 24 constructor calls across 4 test files
- Added version compatibility for V_3_4_0
- All gradle build and test commands pass locally

Signed-off-by: Tanishq Ranjan <[email protected]>
@x-INFiN1TY-x x-INFiN1TY-x force-pushed the EnhanceNodesStatsFileCacheAPI branch from 9820c2c to 2677c17 Compare November 24, 2025 10:08
@github-actions
Copy link
Contributor

❌ Gradle check result for 2677c17: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

❌ Gradle check result for 2677c17: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

❌ Gradle check result for 2677c17: null

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@github-actions
Copy link
Contributor

✅ Gradle check result for 2677c17: SUCCESS

@codecov
Copy link

codecov bot commented Nov 25, 2025

Codecov Report

❌ Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.23%. Comparing base (97d3864) to head (2677c17).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
...h/index/store/remote/filecache/FileCacheStats.java 69.23% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19656      +/-   ##
============================================
- Coverage     73.33%   73.23%   -0.11%     
+ Complexity    71679    71659      -20     
============================================
  Files          5790     5790              
  Lines        327549   327565      +16     
  Branches      47181    47183       +2     
============================================
- Hits         240217   239895     -322     
- Misses        68080    68434     +354     
+ Partials      19252    19236      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gbbafna gbbafna merged commit a0a40bd into opensearch-project:main Nov 27, 2025
40 of 48 checks passed
kkewwei pushed a commit to kkewwei/OpenSearch that referenced this pull request Nov 28, 2025
…e API and fix used_in_bytes field collision (opensearch-project#19656)

Signed-off-by: tanishq ranjan <[email protected]>
rgsriram pushed a commit to rgsriram/OpenSearch that referenced this pull request Dec 5, 2025
…e API and fix used_in_bytes field collision (opensearch-project#19656)

Signed-off-by: tanishq ranjan <[email protected]>
liuguoqingfz pushed a commit to liuguoqingfz/OpenSearch that referenced this pull request Dec 15, 2025
…e API and fix used_in_bytes field collision (opensearch-project#19656)

Signed-off-by: tanishq ranjan <[email protected]>
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.

6 participants