Repository navigation
[Store] Structure FileStorageConfig environment settings - #3525
Conversation
he-yufeng
left a comment
There was a problem hiding this comment.
Read the whole diff against current main and checked the refactor is behavior-preserving, chain by chain:
- All four alias chains keep their precedence: preferred wins when set, legacy fills in, and the two odd corners match the old code. Set-but-empty preferred falls through to the legacy var; set-but-invalid preferred on the ratio and bool vars resolves to the built-in default rather than the legacy value (the scanmeta chain is the exception, invalid preferred still falls to legacy there, same as the old nested GetInt64).
- The ratio parser keeps its exact acceptance surface: classic-locale stream, rejects trailing garbage ("0.75suffix"), nan, non-positive and >1.0, all landing on the default.
- The diagnostics split is preserved: the typed numeric reads log the variable name on garbage, the strict-bool and ratio paths stay silent, and the new tests assert both directions.
ScopedEnvVar saving and restoring the pre-existing value instead of plain unset is the right call; env tests that only unset are order-dependent.
One nit, not blocking: the two uring vars and the watermark bool/ratios are declared as EnvironmentVariablestd::string while their siblings are typed numerics. That is what preserves the custom strict-bool semantics and the silent-on-invalid behavior, so it is intentional, but a one-line comment near the struct would save the next reader a trip to FromEnvironment to learn why.
4dd735f to
764489c
Compare
|
Thanks for the suggestion. I added a comment next to the string-typed bool/ratio definitions to clarify that they intentionally preserve the legacy custom parsing and silent invalid-value behavior. |
764489c to
1804b6e
Compare
1804b6e to
b2fa78f
Compare
| namespace mooncake { | ||
|
|
||
| struct FileStorageEnvironmentVariables { | ||
| inline static constexpr EnvironmentVariable<std::string> |
There was a problem hiding this comment.
Here we can use macro to simplify variable def. e.g.
#define MC_DEFINE_ENV_VAR(Type, Name) \
inline static constexpr EnvironmentVariable<Type> Name{#Name}
MC_DEFINE_ENV_VAR(
int64_t,
MC_STORE_PINNED_RESTORE_ARENA_SIZE_BYTES
);
There was a problem hiding this comment.
Updated all FileStorage environment-variable definitions to use MC_DEFINE_ENV_VAR(Type, Name), with #Name generating the environment-variable string. The macro is undefined after the grouped definitions to avoid leaking it to includers.
b2fa78f to
0e4e394
Compare
Signed-off-by: Schatten <czhengt@qq.com>
0e4e394 to
4fd79a8
Compare
Description
Continue the environment-variable convergence work with
FileStorageConfig::FromEnvironment()as an independent Mooncake Store pilot.This change:
FileStorageConfiginmooncake-common.FileStorageConfigenvironment loading and validation intomooncake-store/src/config/.Environentry point.This PR does not change:
The focused tests cover default values, valid values, invalid values, empty values, legacy alias fallback, preferred-variable precedence, validation behavior, and diagnostic behavior. Further environment-variable convergence can continue module by module after this pilot.
Module
mooncake-store)mooncake-transfer-engine)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Test commands:
Test results:
file_storage_config_testpassed all 13 testsChecklist
./scripts/code_format.shAI Assistance Disclosure
Codex assisted with repository investigation, implementation, test migration, verification, and code review. The human submitter reviewed the changed lines and is responsible for understanding and defending the complete change.