Skip to content

Sandbox/foyer page cache#21202

Merged
bharath-techie merged 10 commits into
opensearch-project:mainfrom
vishwasgarg18:sandbox/foyer-page-cache
May 5, 2026
Merged

Sandbox/foyer page cache#21202
bharath-techie merged 10 commits into
opensearch-project:mainfrom
vishwasgarg18:sandbox/foyer-page-cache

Conversation

@vishwasgarg18
Copy link
Copy Markdown
Contributor

@vishwasgarg18 vishwasgarg18 commented Apr 10, 2026

Description

A disk page cache backed by Foyer for caching Parquet column chunk reads on local NVMe, to be used by DataFusion's TieredObjectStore (as of now). Can be later integrated during write paths etc. as well.

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • [✅] Unit Tests -
glvishwa@bcd074a8699e rust % cargo test
   Compiling opensearch-page-cache v0.1.0 (/Volumes/workplace/OpenSearchOpenSourceNischayWs/OpenSearch/sandbox/libs/page-cache/src/main/rust)
    Finished `test` profile [optimized + debuginfo] target(s) in 38.33s
     Running unittests src/lib.rs (/Volumes/workplace/OpenSearchOpenSourceNischayWs/OpenSearch/sandbox/libs/dataformat-native/rust/target/debug/deps/opensearch_page_cache-c4d94011e167d8e8)

running 33 tests
test foyer::tests::evict_prefix_on_nonexistent_prefix_is_noop ... ok
test foyer::tests::cache_is_usable_after_clear ... ok
test foyer::tests::clear_on_empty_cache_is_safe ... ok
test foyer::tests::concurrent_evict_and_put_does_not_panic ... ok
test foyer::tests::after_evict_prefix_new_put_is_retrievable ... ok
test foyer::tests::evict_prefix_does_not_affect_other_files ... ok
test foyer::tests::ffm_create_with_invalid_utf8_returns_error ... ok
test foyer::tests::ffm_create_with_null_ptr_returns_error ... ok
test foyer::tests::ffm_destroy_with_negative_ptr_returns_error ... ok
test foyer::tests::ffm_destroy_with_zero_ptr_returns_error ... ok
test foyer::tests::evict_prefix_removes_all_ranges_for_file ... ok
test foyer::tests::evict_prefix_twice_is_safe ... ok
test foyer::tests::clear_removes_all_entries ... ok
test foyer::tests::ffm_create_destroy_lifecycle_no_leak ... ok
test foyer::tests::ffm_create_returns_positive_pointer ... ok
test foyer::tests::get_returns_exact_bytes_that_were_put ... ok
test foyer::tests::get_returns_none_for_unknown_key ... ok
test foyer::tests::large_value_round_trips_correctly ... ok
test foyer::tests::get_returns_none_for_wrong_range_on_known_path ... ok
test foyer::tests::key_index_is_empty_after_clear ... ok
test foyer::tests::key_index_has_no_entry_for_evicted_file ... ok
test foyer::tests::event_remove_after_evict_prefix_does_not_panic_or_corrupt_key_index ... ok
test range_cache::tests::range_key_contains_separator ... ok
test range_cache::tests::range_keys_for_different_paths_do_not_share_prefix ... ok
test range_cache::tests::range_keys_for_same_path_share_index_prefix ... ok
test foyer::tests::put_and_get_work_after_cache_nears_capacity ... ok
test foyer::tests::multiple_files_are_independent ... ok
test foyer::tests::put_same_key_twice_replaces_value ... ok
test foyer::tests::multiple_ranges_for_same_file_are_independent ... ok
test foyer::tests::concurrent_puts_to_different_files_do_not_corrupt ... ok
test foyer::tests::replace_event_does_not_duplicate_key_in_key_index ... ok
test foyer::tests::concurrent_put_and_get_same_file_does_not_panic ... ok
test foyer::tests::lru_eviction_removes_stale_keys_from_key_index ... ok

test result: ok. 33 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.58s

   Doc-tests opensearch_page_cache

running 1 test
test /Volumes/workplace/OpenSearchOpenSourceNischayWs/OpenSearch/sandbox/libs/page-cache/src/main/rust/src/range_cache.rs - range_cache::range_cache_key (line 74) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.84s
  • Functionality includes testing. -> Pending
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@vishwasgarg18 vishwasgarg18 requested a review from a team as a code owner April 10, 2026 13:11
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

PR Code Analyzer ❗

AI-powered 'Code-Diff-Analyzer' found issues on commit 37715ae.

PathLineSeverityDescription
sandbox/libs/page-cache/src/main/rust/Cargo.toml14highNew external crate dependency 'foyer = "0.22"' added. Per mandatory supply chain rule, any new package dependency must be flagged regardless of apparent legitimacy. Maintainers should verify the crate name, version, and publisher on crates.io to rule out typosquatting or namespace hijacking before merging.

The table above displays the top 10 most important findings.

Total: 1 | Critical: 0 | High: 1 | Medium: 0 | Low: 0


Pull Requests Author(s): Please update your Pull Request according to the report above.

Repository Maintainer(s): You can bypass diff analyzer by adding label skip-diff-analyzer after reviewing the changes carefully, then re-run failed actions. To re-enable the analyzer, remove the label, then re-run all actions.


⚠️ Note: The Code-Diff-Analyzer helps protect against potentially harmful code patterns. Please ensure you have thoroughly reviewed the changes beforehand.

Thanks.

@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from 56514be to 668ed6a Compare April 10, 2026 13:22
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
Comment thread sandbox/modules/foyer-page-cache/rust/src/lib.rs Outdated
@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch 2 times, most recently from e1d6186 to cc7d3e3 Compare April 14, 2026 10:27
Copy link
Copy Markdown
Contributor Author

@vishwasgarg18 vishwasgarg18 left a comment

Choose a reason for hiding this comment

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

.

@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from cc7d3e3 to c3354ee Compare April 14, 2026 10:34
Comment thread sandbox/libs/page-cache/src/main/rust/src/foyer/ffm.rs Outdated
Comment thread sandbox/libs/page-cache/src/main/rust/src/foyer/foyer_cache.rs Outdated
Comment thread sandbox/libs/page-cache/src/main/rust/src/traits.rs Outdated
vishwasgarg18

This comment was marked as off-topic.

Comment thread sandbox/libs/dataformat-native/rust/Cargo.toml Outdated
Comment thread sandbox/libs/page-cache/src/main/rust/src/foyer/foyer_cache.rs Outdated
vishwasgarg18

This comment was marked as outdated.

@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from bfb5b53 to c290e04 Compare April 21, 2026 08:12
Copy link
Copy Markdown
Contributor Author

@vishwasgarg18 vishwasgarg18 left a comment

Choose a reason for hiding this comment

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

.

Comment thread sandbox/libs/page-cache/src/main/rust/src/foyer/foyer_cache.rs Outdated
Comment thread sandbox/libs/page-cache/src/main/rust/src/foyer/foyer_cache.rs Outdated
Comment thread sandbox/libs/page-cache/src/main/java/org/opensearch/pagecache/PageCache.java Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

❌ Gradle check result for 6cf1c32: 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?

@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from 6cf1c32 to fa47717 Compare May 5, 2026 05:07
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Persistent review updated to latest commit f736741

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

❌ Gradle check result for f736741: 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?

@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from f736741 to 1b7130d Compare May 5, 2026 05:47
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Persistent review updated to latest commit 1a7f6c0

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

✅ Gradle check result for 1a7f6c0: SUCCESS

@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from 1a7f6c0 to b5b530b Compare May 5, 2026 08:40
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Persistent review updated to latest commit 9479658

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

✅ Gradle check result for 9479658: SUCCESS

@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from 9479658 to 9c9df51 Compare May 5, 2026 09:56
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Persistent review updated to latest commit 9c9df51

@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from 9c9df51 to a77e491 Compare May 5, 2026 10:09
Vishwas Garg and others added 10 commits May 5, 2026 15:39
Signed-off-by: Vishwas Garg <glvishwa@amazon.com>
Signed-off-by: Vishwas Garg <glvishwa@amazon.com>
…errors

Settings (Java):
- Add PageCacheSettings.java with format_cache.block_size (default 64MB)
  and format_cache.io_engine (auto|io_uring|psync, default auto) in
  org.opensearch.index.store.remote.filecache — same package as FileCacheSettings.
- Register both in ClusterSettings.BUILT_IN_CLUSTER_SETTINGS.
- Imports use org.opensearch.core.common.unit.ByteSizeUnit/Value.

Page cache interface:
- Update PageCache.java Javadoc: SSD-tier analog of OS page cache,
  agnostic of entry granularity and backing implementation.

Java FFM layer:
- FoyerPageCache: constructor takes blockSizeBytes + ioEngine params.
- FoyerBridge.createCache: add blockSizeBytes + ioEngine params;
  update FFM FunctionDescriptor with two new arguments.

Rust:
- foyer_cache.rs: build_io_engine_config(choice) accepts auto/io_uring/psync;
  FoyerCache::new takes block_size_bytes + io_engine params; clone io_engine
  before async move closure to avoid borrow-after-move.
- ffm.rs: foyer_create_cache adds block_size_bytes (u64) and
  io_engine_ptr/io_engine_len params.
- tests.rs: update all FoyerCache::new() (4-param) and foyer_create_cache()
  (6-param) call sites; add BLOCK_SIZE/IO_ENGINE constants; add 3 new
  validation tests for blockSizeBytes <= 0 and null ioEngine.
- dataformat-native/rust/Cargo.toml: remove stale foyer-page-cache
  workspace member (sandbox/modules/foyer-page-cache/rust no longer exists).

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>
Signed-off-by: Vishwas Garg <glvishwa@amazon.com>
Signed-off-by: Vishwas Garg <glvishwa@amazon.com>
…rbiddenApisTest

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
…acheService

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>
@vishwasgarg18 vishwasgarg18 force-pushed the sandbox/foyer-page-cache branch from a77e491 to ce483f2 Compare May 5, 2026 10:09
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Persistent review updated to latest commit ce483f2

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

✅ Gradle check result for ce483f2: SUCCESS

@bharath-techie bharath-techie merged commit 7b6de24 into opensearch-project:main May 5, 2026
24 checks passed
imRishN pushed a commit to imRishN/OpenSearch that referenced this pull request May 8, 2026
* Add foyer cache to sandbox module

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>

* Add foyer cache to sandbox module

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>

* Make format cache block_size and io_engine configurable; fix compile errors

Settings (Java):
- Add PageCacheSettings.java with format_cache.block_size (default 64MB)
  and format_cache.io_engine (auto|io_uring|psync, default auto) in
  org.opensearch.index.store.remote.filecache — same package as FileCacheSettings.
- Register both in ClusterSettings.BUILT_IN_CLUSTER_SETTINGS.
- Imports use org.opensearch.core.common.unit.ByteSizeUnit/Value.

Page cache interface:
- Update PageCache.java Javadoc: SSD-tier analog of OS page cache,
  agnostic of entry granularity and backing implementation.

Java FFM layer:
- FoyerPageCache: constructor takes blockSizeBytes + ioEngine params.
- FoyerBridge.createCache: add blockSizeBytes + ioEngine params;
  update FFM FunctionDescriptor with two new arguments.

Rust:
- foyer_cache.rs: build_io_engine_config(choice) accepts auto/io_uring/psync;
  FoyerCache::new takes block_size_bytes + io_engine params; clone io_engine
  before async move closure to avoid borrow-after-move.
- ffm.rs: foyer_create_cache adds block_size_bytes (u64) and
  io_engine_ptr/io_engine_len params.
- tests.rs: update all FoyerCache::new() (4-param) and foyer_create_cache()
  (6-param) call sites; add BLOCK_SIZE/IO_ENGINE constants; add 3 new
  validation tests for blockSizeBytes <= 0 and null ioEngine.
- dataformat-native/rust/Cargo.toml: remove stale foyer-page-cache
  workspace member (sandbox/modules/foyer-page-cache/rust no longer exists).

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>

* Update the cache interface from page-cache to block-cache

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>

* Fix spotless formatting violations in BlockCacheSettings

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>

* Add replaceSignatureFiles jdk-signatures to the forbiddenApisMain, forbiddenApisTest

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>

* Move block cache to a plugin and wire it with native s3 repo

Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>

* Move block cache to a plugin and wire it with Node.java

Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>

* Fix up

Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>

* Removed block cache ITs, will be added when integrating with UnifiedCacheService

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>

---------

Signed-off-by: Vishwas Garg <glvishwa@amazon.com>
Signed-off-by: Bukhtawar Khan <bukhtawa@amazon.com>
Co-authored-by: Vishwas Garg <glvishwa@amazon.com>
Co-authored-by: Bukhtawar Khan <bukhtawa@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-diff-analyzer Maintainer to skip code-diff-analyzer check, after reviewing issues in AI analysis.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants