Repository navigation
[fix] Avoid blocking async KV calls and release manager resources - #242
Conversation
Signed-off-by: ji-huazhong <hzji210@gmail.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab87413735
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| keys = self._generate_keys(metadata.field_names, metadata.global_indexes) | ||
| _, _, custom_meta = self._get_shape_type_custom_backend_meta_list(metadata) | ||
| self.storage_client.clear(keys=keys, custom_backend_meta=custom_meta) | ||
| await self._run_storage_operation(self.storage_client.clear, keys=keys, custom_backend_meta=custom_meta) |
There was a problem hiding this comment.
Make offloaded clears cancellation-safe
When async_clear_partition() or async_clear_samples() is timed out or cancelled after the SDK call starts, cancelling this run_in_executor await only cancels the asyncio wrapper; the worker keeps running and can still delete the keys. Those public flows mark controller rows as clearing before this call and remove their metadata only afterward (transfer_queue/client.py:542-549 and 571-578), so cancellation can leave rows stuck unready even after their payloads are gone until a caller explicitly retries. Defer cancellation until both the worker and controller cleanup have completed, rather than allowing the storage mutation to outlive the clear transaction.
AGENTS.md reference: AGENTS.md:L7-L9
Useful? React with 👍 / 👎.
|
[AI Review] Review of Overall this is a clean and well-motivated fix: offloading A few concrete findings to consider before merging: 1. [High] Cancellation safety on offloaded
|
Clearing tag-only keys can raise an error on KV backends. Cleanup can also leave payloads behind when it uses read metadata: heterogeneous rows have no common fields, and metadata containing only selected fields does not describe everything stored in a row. Have the Python and Rust controllers return complete deletion metadata from `MARK_CLEARING`, grouped by partition and including stored fields that are not ready yet. The client deletes payloads using this metadata before releasing controller metadata and indexes. KV storage calls are skipped only when the controller confirms that no payload fields exist; the storage manager retains its guard against ambiguous empty-field metadata. Apply the same field selection to unlinked public-data cleanup. Whole-partition cleanup gets its metadata directly from `MARK_CLEARING`, eliminating one RPC and the separate partition-metadata fetch. Normal reads, field-only deletion, and public-reference protection retain their existing behavior. Extend the existing tests for tag-only keys, heterogeneous rows, direct sample cleanup with partial fields across partitions, unfinalized fields, and public-data cleanup. Verify each stored field is removed while neighboring data remains readable. Require Yuanrong's `Key not found` error when reading a deleted field; other read errors still fail the assertion. Validation: - All 16 GitHub CI checks passed, including unit tests and Python- and Rust-controller E2E suites with SimpleStorage, MooncakeStore, and Yuanrong. - 98 focused tests passed, including client, controller, checkpoint, and KV manager coverage. - 42 Rust-controller cleanup and public-reference integration tests passed; 18 Rust unit tests passed. - Real Mooncake TCP: all 24 cleanup tests passed. On the previous PR head, six synchronous/asynchronous cases fail because payloads remain after cleanup. - `python -m compileall -q transfer_queue tutorial tests` and all pre-commit checks passed. The local full suite finished with 992 passed and 16 skipped, plus one previously reproduced worker-exit test failure and six Yuanrong fixture errors caused by the missing optional dependency. The corresponding CI unit tests and real Yuanrong integration passed. This PR is based directly on `main` and is independent of #242. --------- Signed-off-by: ji-huazhong <hzji210@gmail.com>
Signed-off-by: ji-huazhong <hzji210@gmail.com>
Signed-off-by: ji-huazhong <hzji210@gmail.com>
Signed-off-by: ji-huazhong <hzji210@gmail.com>
|
Addressed the cancellation, worker-budget, and backend-layering findings in 800b7bf, 0b6af12, and e0ae380.
I did not apply unconditional Validation
Resource and timing comparison Compared the already-offloaded previous PR head
Worker counts include both manager-owned pools, not all process threads. This single-host sample supports the reduced thread budget; it does not show a universal throughput gain. TCP GET was about 7.6% slower and GDR GET about 9.6% faster in this run. |
Signed-off-by: ji-huazhong <hzji210@gmail.com>
|
Fixed the CI failure in 12b994f.
Reproduced with real SimpleStorage through public APIs: write two rows, release them in reverse order, then run the existing consistency test. The previous test fails with Validation:
|
|
[AI Review] Follow-up review of Thanks for the thorough follow-up — the cancellation handling ( One small non-blocking test-hygiene nit:
No blocking issues remain — LGTM. |
Signed-off-by: ji-huazhong <hzji210@gmail.com>
KVStorageManager.get_data()andclear_data()called synchronous backend SDK methods on the event-loop thread. While an SDK call waited, unrelated coroutines on the same loop could not progress. Closing the manager also left its packing executor and Mooncake transfer buffers allocated; the executor finalizer had capturedNonebefore the lazy pool was created.This change runs PUT, GET, and CLEAR SDK calls in a manager-owned executor, preserving the caller's initialized CUDA/NPU device and stream. Closing the manager drains both executors and releases Mooncake receive/staging buffers through the existing
close(unmount=False)method. The shared storage segment stays mounted so other clients can continue reading it; calling the storage client'sclose()without arguments retains its existing full-close behavior.Before and after
The same regression tests were run against the base implementation and this change with real Mooncake TCP and GDR backends:
The 5 s gate is a deterministic blocking regression, not a storage latency benchmark.
Performance
Measured on the same Linux host with Mooncake 0.3.14, comparing base
3727c64withab87413. These are real SDK calls with no injected delay. Each GET reads 32 samples with two float32 fields of 8,192 elements each (2 MiB per request); CLEAR removes one field from the same 32 samples. TCP uses CPU tensors, and GDR uses CUDA tensors. Concurrency 8 submits eight disjoint requests withasyncio.gather. Each case has 5 warm-up rounds and 20 measured rounds. Values are medians across rounds; heartbeat delay is each round's maximum lateness of a 1 ms asyncio timer.After
manager.close(), both base runs still had 2 packing workers alive. With the fix, all manager-owned I/O and packing workers stopped (0 of 30 remaining for TCP, 0 of 34 for GDR).This measures local backend calls and manager scheduling, not network bandwidth or training speed. Offloading adds overhead to short calls, including the measured CLEAR workload; the main benefit is keeping the event loop responsive during SDK waits. Result packing remains on the original calling side.
Validation
compilealland pre-commit checks passed.