Repository navigation
[Store] Remove redundant alignment headroom from DFS shard allocation - #4753
Merged
Merged
Conversation
Shard allocators start at offset 0 and only get alignment-multiple requests, so returned offsets are already aligned. The extra alignment - 1 bytes only pushed on-class sizes into the next size class (e.g. 1 MiB reserved 1.125 MiB). Request the aligned size and check the offset instead of rounding it.
ykwd
approved these changes
Oct 19, 2026
ykwd
requested changes
Oct 19, 2026
ykwd
left a comment
Collaborator
There was a problem hiding this comment.
Sorry, I accidentally clicked Approve by mistake. Will initiate the review process as soon as possible.
fcczzz
reviewed
Oct 19, 2026
fcczzz
left a comment
Collaborator
There was a problem hiding this comment.
Could you update the DFS deployment guide to match this change? It still says shard allocations require an additional MOONCAKE_DFS_ALIGNMENT - 1 bytes of padding, including in the limitations section.
Please clarify that shard allocations no longer need leading alignment padding because they start at offset 0 and preserve alignment through size-class rounding, splitting, and coalescing. Size-class rounding can still reserve more than aligned_size.
2xdevv
requested review from
ShangmingCai,
UNIDY2002,
alogfans and
staryxchen
as code owners
October 20, 2026 03:10
Contributor
Author
|
Hello @fcczzz. Just updated the DFS deployment guide with the things you've mentioned. |
ykwd
approved these changes
Oct 20, 2026
zxpdemonio
added a commit
to zxpdemonio/Mooncake
that referenced
this pull request
Oct 21, 2026
…20261021 * upstream/main: (507 commits) [Reshard] Plan Store KV reuse across TP, PP and host layouts (kvcache-ai#4762) [Store] Walk tenants through shard-backed cursors and build the removes on them (kvcache-ai#4796) [Store-RS][Bugfix] Match TENT Request Layout to the C ABI (kvcache-ai#4732) [TransferEngine] Recover auto GID after data-path retry exhaustion (kvcache-ai#4290) [Store] Add the namespace layer over the object route (kvcache-ai#4721) [Store] Fix silent loss of offload keys deferred to the ungrouped pool (kvcache-ai#3006) (kvcache-ai#3009) [Store] Remove redundant alignment headroom from DFS shard allocation (kvcache-ai#4753) [CI/Build] Gate ROCm hardware tests and bound nightly Docker builds (kvcache-ai#4750) [Bugfix][Store] Fix double-counting of segment OpLog metrics in OpLogApplier (kvcache-ai#4771) [Store] Skip hot-cache writeback for device-resident read destinations (kvcache-ai#4764) [Reshard] Add bounded in-flight execution for weight transfers (kvcache-ai#4628) [Store] Avoid racing with detached hot-cache fills during key scans (kvcache-ai#4334) [Store] HA: drain the master on SIGTERM/SIGINT before exit (part 1 of kvcache-ai#4710) (kvcache-ai#4745) TENT: report a notification the receiver could not take (kvcache-ai#4754) [Store] Reach object metadata through a per-key accessor contract (kvcache-ai#4717) [Store][Bugfix] Fix DFS sync client test retry failure (kvcache-ai#4781) [Wheel] Keep integer dtype for typed_ragged rows when a row is an empty list (kvcache-ai#4611) [Doc] Sync README news onto the docs homepage (kvcache-ai#4767) [CI] remove stale Torch version binding after PG JIT (kvcache-ai#4760) [TransferEngine] Add buffer-protocol and page-gathered batch transfer APIs (kvcache-ai#4763) ...
zxpdemonio
added a commit
to zxpdemonio/Mooncake
that referenced
this pull request
Oct 21, 2026
…-ranges-20261021 * upstream/main: (394 commits) [Reshard] Plan Store KV reuse across TP, PP and host layouts (kvcache-ai#4762) [Store] Walk tenants through shard-backed cursors and build the removes on them (kvcache-ai#4796) [Store-RS][Bugfix] Match TENT Request Layout to the C ABI (kvcache-ai#4732) [TransferEngine] Recover auto GID after data-path retry exhaustion (kvcache-ai#4290) [Store] Add the namespace layer over the object route (kvcache-ai#4721) [Store] Fix silent loss of offload keys deferred to the ungrouped pool (kvcache-ai#3006) (kvcache-ai#3009) [Store] Remove redundant alignment headroom from DFS shard allocation (kvcache-ai#4753) [CI/Build] Gate ROCm hardware tests and bound nightly Docker builds (kvcache-ai#4750) [Bugfix][Store] Fix double-counting of segment OpLog metrics in OpLogApplier (kvcache-ai#4771) [Store] Skip hot-cache writeback for device-resident read destinations (kvcache-ai#4764) [Reshard] Add bounded in-flight execution for weight transfers (kvcache-ai#4628) [Store] Avoid racing with detached hot-cache fills during key scans (kvcache-ai#4334) [Store] HA: drain the master on SIGTERM/SIGINT before exit (part 1 of kvcache-ai#4710) (kvcache-ai#4745) TENT: report a notification the receiver could not take (kvcache-ai#4754) [Store] Reach object metadata through a per-key accessor contract (kvcache-ai#4717) [Store][Bugfix] Fix DFS sync client test retry failure (kvcache-ai#4781) [Wheel] Keep integer dtype for typed_ragged rows when a row is an empty list (kvcache-ai#4611) [Doc] Sync README news onto the docs homepage (kvcache-ai#4767) [CI] remove stale Torch version binding after PG JIT (kvcache-ai#4760) [TransferEngine] Add buffer-protocol and page-gathered batch transfer APIs (kvcache-ai#4763) ...
9 tasks done
daegyu94
pushed a commit
to daegyu94/Mooncake
that referenced
this pull request
Oct 23, 2026
Since kvcache-ai#4753, 100-byte allocations reserve 4 KiB instead of 8 KiB, so four of them only fill half of the 32 KiB shard and never trigger eviction. Use 8192-byte payloads to keep the shard full and assert the initial preparation returns two candidates so the restore paths run.
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
ShardAllocator::Allocaterequestsaligned_size + alignment - 1bytes from the shard'sOffsetAllocatorand then rounds the returned offset up to the alignment. That slack is only needed when the allocator can return unaligned offsets, and here it can't:So the returned offset is always aligned, and the extra
alignment - 1bytes are never used. They do cost space, though: when the aligned size is exactly a size class, the extra bytes push the request into the next class.This PR requests
aligned_sizedirectly. Since there is no longer slack to round into, the offset rounding is replaced by a check that fails the allocation withINTERNAL_ERRORif the offset is ever unaligned. Normalized reservation accounting (reserved_bytes, used bytes, deferred frees, eviction) is unchanged. Only the shard (POSIX/HF3FS) path is affected;ImmutableBucketAllocatorand DSB object mode are not.Objects per shard, 4 KiB alignment, measured by filling the unchanged
OffsetAllocator:Payloads whose aligned size is exactly a size class, which includes powers of two, save about 11–12%. Other sizes reserve the same as before. An object whose aligned size equals the shard capacity now fits; it was previously rejected. This is a capacity gain only; I have not measured serving latency or hit rate.
Interaction with #4018 (draft): its recovery validation requires
requested_size == aligned_size + alignment - 1, so it would reject allocations made after this change. That check would need to acceptrequested_size == aligned_size. Layouts produced by the old code are also aligned, so recovering a mix of old and new records is safe. #3787 (finer size classes) is independent: it narrows the class steps, but on-class sizes still cross into the next class with the old headroom.Suggested Merge Priority
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)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?
New tests:
ShardAllocatorTest.MegabytePayloadsPackWithoutAlignmentHeadroomfills a 32 MiB shard with 1–8 MiB payloads, checks count, back-to-back offsets and used bytes, then writes a distinct pattern into every object through the POSIX backend and reads each one back.ShardAllocatorTest.MixedMegabytePayloadsStayAlignedAcrossReusemixes odd MB sizes at 4 KiB, 64 KiB and 1 MiB alignment over repeated free/refill rounds, checking alignment and no overlap.ShardAllocatorTest.AllocateReservesOnlyAlignedSizereplacesAllocateReservesAlignmentPadding, which asserted the old padding.Hf3fsAdapterTest.ShardAllocatorPacksMegabytePayloadsdoes the same MB packing and readback through the native 3FS I/O path.The first three fail on the original code; for example, 1 MiB objects land 1.125 MiB apart.
Tests that relied on a 100-byte object reserving 8 KiB to fill a small shard or cross eviction watermarks now use 8 KiB objects, so they check the same behavior as before.
Test commands:
Test results:
dfs_posix_test(55),offset_allocator_test(56),master_service_dfs_scenario_test(6),master_service_test(69),master_admin_server_test(63),dfs_sync_client_test(12),distributed_storage_config_test(10),pybind_client_testDFS case (1)dfs_hf3fs_test(5) on a local single-node 3FS clusterChecklist
./scripts/code_format.shAI Assistance Disclosure
Claude Code helped verify the alignment invariant against the allocator code, implement the change and tests, and run the test suites locally and on 3FS. I have reviewed every changed line.