Skip to content

[MP] Introduce l2 mooncake adapter#2911

Merged
maobaolong merged 3 commits intoLMCache:devfrom
maobaolong:l2_mooncake
Apr 3, 2026
Merged

[MP] Introduce l2 mooncake adapter#2911
maobaolong merged 3 commits intoLMCache:devfrom
maobaolong:l2_mooncake

Conversation

@maobaolong
Copy link
Copy Markdown
Collaborator

@maobaolong maobaolong commented Mar 30, 2026

What this PR does / why we need it:

  • run mooncake master
mooncake_master --config_path=/tmp/master_config.json
  • /tmp/master_config.json
{
    "enable_metric_reporting": false,
    "rpc_port": 50051,
    "rpc_thread_num": 4,
    "rpc_address": "0.0.0.0",
    "rpc_conn_timeout_seconds": 0,
    "rpc_enable_tcp_no_delay": true,
    "default_kv_lease_ttl": 5000,
    "default_kv_soft_pin_ttl": 1800000,
    "allow_evict_soft_pinned_objects": true,
    "eviction_ratio": 0.1,
    "eviction_high_watermark_ratio": 1.0,
    "enable_ha": false,
    "root_fs_dir": "",
    "cluster_id": "mooncake_cluster",
    "memory_allocator": "offset",
    "client_live_ttl_sec": 60,
    "enable_http_metadata_server": true,
    "http_metadata_server_host": "0.0.0.0",
    "http_metadata_server_port": 8080
}
  • run mooncake_store_l2_adapter basic check
import json
import subprocess
import sys

config = json.dumps({
    "type": "mooncake_store",
    "local_hostname": "192.168.100.227",
    "metadata_server": "P2PHANDSHAKE",
    "protocol": "tcp",
    "global_segment_size": "3221225472",
    "local_buffer_size": "3221225472",
    "master_server_address": "127.0.0.1:50051",
})

r = subprocess.run(
    [
        sys.executable,
        "-m",
        "lmcache.v1.basic_check",
        "--mode",
        "test_l2_adapter",
        "--obj-size","16777216","--num-keys","80","--settle-time","10",
        "--l2-adapter",
        config,
    ],
)
sys.exit(r.returncode)
  • log
[2026-04-01 22:20:56,362] LMCache INFO: Created Mooncake Store L2 adapter (workers=4) (mooncake_store_l2_adapter.py:126:lmcache.v1.distributed.l2_adapters.mooncake_store_l2_adapter)
=== Testing L2 adapter #0 (NativeConnectorL2Adapter) ===
Phase 1: Lookup non-existing keys...
  Validation: 80/80 correctly absent
Phase 2: Store operations (batch of 80)...
  Batch store OK (1308.58ms)
  Waiting 10.0s for data to settle...
Phase 3: Lookup existing keys...
  Validation: 80/80 found
Phase 4: Load operations...
  Validation (loaded): 80/80
  Validation (content): 80/80

Performance Results:
----------------------------------------------------------------------------------------------------------------------
| Operation            |     Avg (ms) |     Max (ms) |     Min (ms) |   Pass/All |  Pass Rate | |   Throughput  
----------------------------------------------------------------------------------------------------------------------
| LOOKUP (absent)      |     1.815367 |     1.815367 |     1.815367 |      80/80 |     100.0% | |       -       
| STORE                |  1308.577698 |  1308.577698 |  1308.577698 |      80/80 |     100.0% | |   1.91 GB/s   
| LOOKUP (exist)       |     1.542881 |     1.542881 |     1.542881 |      80/80 |     100.0% | |       -       
| LOAD                 |   622.296274 |   622.296274 |   622.296274 |      80/80 |     100.0% | |   4.02 GB/s   
----------------------------------------------------------------------------------------------------------------------

Special notes for your reviewers:

If applicable:

  • this PR contains user facing changes - docs added
  • this PR contains unit tests

Note

Medium Risk
Adds a new optional native (C++/pybind) storage backend and wires it into MP L2 adapter creation/build tooling, which can affect build/link behavior and runtime storage correctness when enabled.

Overview
Introduces a new MP L2 adapter type, mooncake_store, backed by an optional native C++ Mooncake connector exposed via a new lmcache.lmcache_mooncake pybind module.

Build/install is updated to conditionally compile and link the Mooncake extension via BUILD_MOONCAKE/MOONCAKE_INCLUDE_DIR/MOONCAKE_LIB_DIR, and docs are extended with configuration/build instructions and the note that mooncake_store has no eviction support.

Adds unit tests for config parsing/registry behavior plus integration tests (skipped unless the extension and a Mooncake service are available), and fixes the RESP integration test to import RESPL2AdapterConfig from the correct module.

Written by Cursor Bugbot for commit 9c65dc7. This will update automatically on new commits. Configure here.

@maobaolong maobaolong marked this pull request as draft March 30, 2026 15:27
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a native C++ connector and L2 adapter for Mooncake Store and refactors the RESP and Filesystem native adapters into dedicated modules. Key feedback includes the requirement for integration tests for the new Mooncake feature per the style guide. Additionally, the Mooncake C++ connector requires fixes for error handling in existence checks, removal of unsafe type casting, and making the hardcoded replication count configurable.

Comment thread lmcache/v1/distributed/l2_adapters/mooncake_store_l2_adapter.py
Comment thread csrc/storage_backends/mooncake/connector.cpp Outdated
Comment thread csrc/storage_backends/mooncake/connector.cpp Outdated
Comment thread csrc/storage_backends/mooncake/connector.cpp Outdated
@maobaolong maobaolong marked this pull request as ready for review April 1, 2026 14:34
Comment thread setup.py Outdated
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Comment thread lmcache/v1/distributed/l2_adapters/fs_native_l2_adapter_config.py Outdated
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread setup.py Outdated
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
@maobaolong maobaolong added the full Run comprehensive tests on this PR label Apr 3, 2026
@maobaolong
Copy link
Copy Markdown
Collaborator Author

@sammshen Would you like to take a look at this PR? Thanks! Base on this, the contributor from mooncake community can help to submit another PR to improve the performance.

Copy link
Copy Markdown
Contributor

@sammshen sammshen left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Collaborator

@chunxiaozheng chunxiaozheng left a comment

Choose a reason for hiding this comment

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

LGTM!

@maobaolong maobaolong merged commit ccaf38d into LMCache:dev Apr 3, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full Run comprehensive tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants