Repository navigation
[Store] Make Environ an injectable environment reader - #4401
Merged
Merged
Conversation
This was referenced Sep 29, 2026
Environ was a process-wide singleton that eagerly cached ~40 settings, most of them unused, plus static helpers that called getenv() directly, so every config loader was tied to the real process environment. Turn it into a reader over an injectable EnvironSource: production reads through Environ::Process() (the live process environment) and tests can inject a MapEnvironSource. The API is Get/GetTyped/GetTypedOr/GetList, and environ.h moves to mooncake-common/src, exported only to in-tree targets. The settings still in use move to their owners and are still resolved once per process: the RPC client I/O thread counts to RpcClientIoThreadsConfig, and the Transfer Engine's WITH_NVIDIA_PEERMEM, MC_RDMA_DATA_DIRECT and MC_EFA_CQ_THREADS to its GlobalConfig, next to its other environment settings. The static Read/ReadOr/GetDouble remain as compatibility wrappers over Process() so Store configs are unchanged; a follow-up migrates them and removes the wrappers.
Aionw
force-pushed
the
refactor/environ-reader
branch
from
September 29, 2026 12:44
7d261e5 to
033333b
Compare
Aionw
marked this pull request as ready for review
September 29, 2026 12:49
Aionw
requested review from
XucSh,
YiXR,
alogfans,
chestnut-Q,
doujiang24,
staryxchen,
stmatengss,
whn09 and
ykwd
as code owners
September 29, 2026 12:49
ykwd
approved these changes
Sep 30, 2026
alogfans
approved these changes
Oct 8, 2026
This was referenced Oct 8, 2026
pingqiu
added a commit
to pingqiu/Mooncake
that referenced
this pull request
Oct 8, 2026
…on API kvcache-ai#4401 removed Environ::GetBool and Environ::Get(), while two call sites that landed around the same time still use them, so main does not compile: - real_client.cpp (kvcache-ai#3665) calls Environ::GetBool for MOONCAKE_ENABLE_EMBEDDED_MASTER. Declare the variable in environment_variables.h and read it with Environ::ReadOr. - rdma_transport.cpp (kvcache-ai#4329, USE_CUDA only) calls Environ::Get().GetRdmaDataDirect(). Use globalConfig().rdma_data_direct, as kvcache-ai#4401 did in rdma_context.cpp. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Aionw
added a commit
to Aionw/Mooncake
that referenced
this pull request
Oct 8, 2026
…R registration kvcache-ai#4329 reads MC_RDMA_DATA_DIRECT in RdmaTransport::registerLocalMemoryInternal through Environ::Get().GetRdmaDataDirect(). kvcache-ai#4401, merged after it, removed that accessor and moved the setting to GlobalConfig::rdma_data_direct. The call is inside #ifdef USE_CUDA, so only CUDA builds fail. Read globalConfig().rdma_data_direct, as rdma_context.cpp already does. Both parse MC_RDMA_DATA_DIRECT with TryParseBool and fall back to false on an invalid value.
8 of 32 tasks
200lz
added a commit
to 200lz/Mooncake
that referenced
this pull request
Oct 8, 2026
The rebased Store build still calls Environ::GetBool, removed by kvcache-ai#4401. Include the current reader definition and use its typed ReadOr API for the two embedded-master checks. Preserve the environment key, false default, canonical boolean parser, and invalid-value diagnostics.
13 of 32 tasks
quantz8a
pushed a commit
to quantz8a/Mooncake
that referenced
this pull request
Oct 9, 2026
kvcache-ai#3665 reads MOONCAKE_ENABLE_EMBEDDED_MASTER in real_client.cpp through Environ::GetBool, and kvcache-ai#4401, merged after it, removed that static helper. Each change built on its own branch, but main no longer compiles mooncake_store. Define MOONCAKE_ENABLE_EMBEDDED_MASTER in the environment variable catalog and read it with Environ::Process().GetTypedOr(..., false). This keeps the previous behavior: an unset value is false, the canonical boolean spellings are accepted, and an invalid value warns and falls back to false. (cherry picked from commit 25958ec)
quantz8a
pushed a commit
to quantz8a/Mooncake
that referenced
this pull request
Oct 9, 2026
…R registration kvcache-ai#4329 reads MC_RDMA_DATA_DIRECT in RdmaTransport::registerLocalMemoryInternal through Environ::Get().GetRdmaDataDirect(). kvcache-ai#4401, merged after it, removed that accessor and moved the setting to GlobalConfig::rdma_data_direct. The call is inside #ifdef USE_CUDA, so only CUDA builds fail. Read globalConfig().rdma_data_direct, as rdma_context.cpp already does. Both parse MC_RDMA_DATA_DIRECT with TryParseBool and fall back to false on an invalid value. (cherry picked from commit b41aeac)
alogfans
pushed a commit
that referenced
this pull request
Oct 9, 2026
* [Bugfix][Store] Restore the build after Environ::GetBool removal #3665 reads MOONCAKE_ENABLE_EMBEDDED_MASTER in real_client.cpp through Environ::GetBool, and #4401, merged after it, removed that static helper. Each change built on its own branch, but main no longer compiles mooncake_store. Define MOONCAKE_ENABLE_EMBEDDED_MASTER in the environment variable catalog and read it with Environ::Process().GetTypedOr(..., false). This keeps the previous behavior: an unset value is false, the canonical boolean spellings are accepted, and an invalid value warns and falls back to false. * [Bugfix][TransferEngine] Read Data Direct from globalConfig in CUDA MR registration #4329 reads MC_RDMA_DATA_DIRECT in RdmaTransport::registerLocalMemoryInternal through Environ::Get().GetRdmaDataDirect(). #4401, merged after it, removed that accessor and moved the setting to GlobalConfig::rdma_data_direct. The call is inside #ifdef USE_CUDA, so only CUDA builds fail. Read globalConfig().rdma_data_direct, as rdma_context.cpp already does. Both parse MC_RDMA_DATA_DIRECT with TryParseBool and fall back to false on an invalid value.
10 tasks done
10 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of #3809. Replaces #4388, whose earlier revision was too large; see the review there. This is the first of three stacked PRs. It is behavior-preserving and does not change any Store config.
Environwas a process-wide singleton. It eagerly cached about 40 settings, most of them unused, and it exposed static helpers that calledgetenv()directly. That tied every config loader to the real process environment.This PR turns it into a reader over an injectable source:
Environ(mooncake-common/src/environ.h) reads through anEnvironSource.Environ::Process()reads the live process environment. It behaves as before and takes no snapshot.MapEnvironSource.Get,GetTyped,GetTypedOrandGetList, over the existing typed parser.mooncake-common/srcand is exported only to in-tree targets, throughmooncake_common'sBUILD_INTERFACE.RpcClientIoThreadsConfig(common).WITH_NVIDIA_PEERMEM,MC_RDMA_DATA_DIRECTandMC_EFA_CQ_THREADS→ the Transfer Engine'sGlobalConfig, loaded byloadGlobalConfig()next to its other environment settings. Parsing and defaults are unchanged.Read,ReadOrandGetDoublestay as thin wrappers overProcess()with the previous behavior, so no Store config changes here. The next PR migrates the configs and removes these wrappers.Stack:
EnvironModule
mooncake-common)mooncake-transfer-engine)mooncake-store)Type of Change
How Has This Been Tested?
environ_test(injection, typed reads, lists, and the compatibility wrappers) andrpc_client_io_threads_test.Checklist
./scripts/code_format.shAI Assistance Disclosure
Claude Code (Claude Opus) assisted with the refactor and verification. I reviewed every changed line.