Skip to content

[Store] Support 512MB hugepage size for client buffer allocation - #3789

Merged
ykwd merged 2 commits into
kvcache-ai:mainfrom
Kevin-XiongC:store-512mb-hugepage
Sep 2, 2026
Merged

ykwd merged 2 commits into
kvcache-ai:mainfrom
Kevin-XiongC:store-512mb-hugepage

Conversation

@Kevin-XiongC

@Kevin-XiongC Kevin-XiongC commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Description

Add support for 512MB hugepages in Mooncake Store's client buffer allocation paths. 512MiB is the PMD hugepage size on arm64 kernels running with 64K base pages, where 2MB pages give poor TLB coverage and 1GB pages are unavailable (Like GB200,GB300).

  • MC_STORE_HUGEPAGE_SIZE now accepts 512MB in addition to 2MB/1GB (get_hugepage_size_from_env, allocate_buffer_numa_segments).
  • Provide MAP_HUGE_512M / MFD_HUGE_512M fallbacks for older glibc/kernel headers that do not define them.
  • MmapArena now honors the configured hugepage size: it aligns the pool to the configured page size, passes the size-specific MAP_HUGE_* flag to mmap(), and strips the size bits on the no-hugepage retry.
  • Document 512MB in the store deployment guide.

Module

  • Transfer Engine (mooncake-transfer-engine)
  • Mooncake Store (mooncake-store)
  • Reshard (mooncake-reshard)
  • Mooncake EP (mooncake-ep)
  • Mooncake PG (mooncake-pg)
  • Integration (mooncake-integration)
  • P2P Store (mooncake-p2p-store)
  • Python Wheel (mooncake-wheel)
  • Common (mooncake-common)
  • Mooncake RL (mooncake-rl)
  • CI/CD
  • Docs
  • Other

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Breaking change
  • Documentation update
  • Performance improvement
  • Other

How Has This Been Tested?

Validated on an arm64 Linux host (64K base pages) with 512MB HugeTLB pages reserved: client buffers are allocated with MAP_HUGE_512M and serve reads/writes correctly. Unit tests for the new size parsing are added in this PR and run in CI.

Test commands:

# On an arm64 host with 512MB hugepages reserved:
MC_STORE_USE_HUGEPAGE=1 MC_STORE_HUGEPAGE_SIZE=512MB ./build/mooncake-store/tests/mooncake_store_tests

Test results:

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing done (describe below)

Manual testing: ran mooncake-store client with MC_STORE_USE_HUGEPAGE=1 MC_STORE_HUGEPAGE_SIZE=512MB on an arm64 host with 512MB HugeTLB pages; verified mappings use 512MB pages via /proc/self/smaps (KernelPageSize/Hugetlb) and that put/get traffic works.

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have updated the documentation (if applicable)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (specify below)

Kimi Code CLI helped prepare this PR branch (rebasing the change onto latest main, adding the HugepageSizeEnvTest unit tests, running pre-commit). The human submitter has reviewed every changed line and is responsible for the change.

Comment thread mooncake-store/include/utils.h Outdated

// 512MiB hugepages (PMD size on arm64 kernels with 64K base pages) are not
// defined by older glibc/kernel headers; provide fallbacks.
#ifndef MAP_HUGE_512M

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Linux UAPI names these constants MAP_HUGE_512MB and MFD_HUGE_512MB. Since the guards check the non-standard *_512M names, they always define private aliases even when the system headers provide the constants. Please use the standard names directly, or guard and define those exact names if old-header compatibility is required.

@github-actions github-actions Bot added documentation Improvements or additions to documentation run-ci Store labels Aug 31, 2026

@Aionw Aionw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Kevin-XiongC

Kevin-XiongC commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor Author

The single failing job, test-wheel-ubuntu (ubuntu-22.04, 3.12), fails in mooncake-pg/tests/test_pg_elastic.py::test_recovery_p2p_after_graceful_group_destroy (rank 0 P2P failure + rank 2 replacement timeout over TCP transport). This is unrelated to this PR: the change only touches mooncake-store (hugepage size handling) and mooncake-pg neither includes nor links any mooncake-store code. All store-related checks pass, including CTest unit tests (which covers the new HugepageSizeEnvTest cases), Check code format, and the wheel builds.

Maybe re-run the failed job? It looks like a flaky PG elastic test on the runner. Thanks!

512MiB is the PMD hugepage size on arm64 kernels running with 64K base
pages, where 2MB pages give poor TLB coverage and 1GB pages are
unavailable.

- MC_STORE_HUGEPAGE_SIZE now accepts 512MB in addition to 2MB/1GB
  (get_hugepage_size_from_env, allocate_buffer_numa_segments).
- Provide MAP_HUGE_512M / MFD_HUGE_512M fallbacks for older
  glibc/kernel headers that do not define them.
- MmapArena honors the configured hugepage size: align the pool to it,
  pass the size-specific MAP_HUGE_* flag to mmap(), and strip the size
  bits on the no-hugepage retry.
- Document 512MB in the store deployment guide.
The Linux UAPI spells these constants with a trailing 'B'
(MAP_HUGE_512MB in asm-generic/mman-common.h, MFD_HUGE_512MB in
linux/memfd.h). Guard and define the standard names so the fallbacks
only kick in on headers that genuinely lack them.
@Kevin-XiongC

Copy link
Copy Markdown
Contributor Author

CI has passed. Can somebody merge it?

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 run-ci Store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants