[Store] Add Fast-Fail for Impossible OffsetAllocator Requests - #3222
Open
bitborne wants to merge 3 commits into
Open
[Store] Add Fast-Fail for Impossible OffsetAllocator Requests#3222bitborne wants to merge 3 commits into
bitborne wants to merge 3 commits into
Conversation
Signed-off-by: Schatten <czhengt@qq.com>
Signed-off-by: Schatten <czhengt@qq.com>
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Signed-off-by: Schatten <czhengt@qq.com>
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
Cache a conservative upper-bound hint for the largest allocatable free region in
OffsetAllocatorand use it to reject impossible requests before acquiring the allocator mutex.The main changes are:
OffsetAllocatorcalls and the same-segment Put allocation stage, including capacity pressure, deterministic fragmentation, configurable mixed success/failure ratios, and a successful allocate/free control.The mutex-protected allocator remains authoritative. A stale larger hint can only allow a request to fall through to the existing locked path; it cannot make an invalid allocation succeed. The first locked failure tightens the hint for later requests.
memory_order_relaxedis sufficient because the atomic value is only a filtering hint and does not publish or protect allocator metadata.This change is complementary to #2445 and #2797, which use the largest free region to rank segments but do not modify
OffsetAllocatorinternals. It also avoids replacing the current mutex with a shared mutex, as discussed in the closed PR #2695.Module
mooncake-transfer-engine)mooncake-store)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:
The A/B benchmark used
RelWithDebInfobuilds on the same host, pinned to CPUs 0-15. Throughput and per-operation latency were measured in separate phases. Each long-running result below contains 16 million measured operations.The high-water workloads use a 1 GiB allocator at 93.75% actual utilization, with a 64 MiB largest free region. Successful operations allocate and immediately release 4 KiB. Expected-failure operations request 128 MiB and therefore cannot fit. For example, a 30% mixed workload contains approximately 30 expected failures and 70 successful allocate/free operations per 100 attempts.
First, the lazy upper-bound policy was compared with the eager policy that refreshed the atomic value after every successful allocation. The binaries used the same benchmark and differed only in the hint-update policy.
This comparison shows that avoiding the successful-allocation refresh recovers a substantial part of the eager policy's success-path cost while preserving the fast-fail behavior.
The final lazy-hint implementation was also compared with the upstream allocator, which has no atomic pre-check:
The mixed results make the trade-off explicit: the synthetic workload crosses into positive aggregate throughput near a 30% impossible-request ratio. The successful control intentionally frees every allocation, so it exercises the remaining free-time refresh on every operation; append/write-once workloads are expected to refresh less frequently.
The benchmark also covers the same-segment Put allocation stage and deterministic fragmentation. All benchmark runs completed with zero unexpected results in both the throughput and latency phases.
User-space lock profiling was performed on the eager-refresh fast-fail variant using a
pthread_mutex_lockuprobe and thesyscalls:sys_enter_futextracepoint. Across 3,232,000 measured and warmup allocation attempts,pthread_mutex_lockcalls decreased from 3,232,057 to 57 and futex syscalls decreased from 1,197,395 to 22. The final lazy policy retains the same repeated-request fast path after the first mutex-protected failure tightens the hint. QPS measured while perf probes were active was not used because probe overhead affects the two implementations asymmetrically.Test results:
The complete
OffsetAllocatorTestsuite passed: 46/46 tests. The tests cover hint tightening after failure, refresh after free, serialization/deserialization, SmallFloat bin boundaries, multiplier values 1 through 4, and mutex-free rejection after the hint has been tightened.Checklist
./scripts/code_format.shAI Assistance Disclosure
Tool: OpenAI Codex
Used for code navigation, implementing the allocator changes, drafting unit tests and benchmark scenarios, and reviewing implementation details and benchmark results. The submitter reviewed every changed line and is responsible for understanding and defending the changes.