Custom Memory Resource and Extensible Memory Management #17436
Replies: 5 comments 5 replies
|
cc: @kgpai @xiaoxmeng |
|
I am heavily in favour of adding tiered tracking and arbitration to Velox. I have some thoughts:
I don't think we can escape this. Arbitration currently consists of reservation management AND spilling. If GPU memory is full, it must spill. And it's best to spill to host memory. This means GPU memory arbitration triggers allocation from CPU memory pools. And this has the potential to cause some locking issue somewhere. Additionally, all CPU memory isn't the same as far as transfers from GPU is concerned. Pinned memory (allocated from |
|
@sungwoo-XCENA thanks for starting this proposal. Having memory management extensible with a user-provided adapter makes sense to me, so that users can provide their own extensions of memory management. Is the idea here that we mostly want to do this from a tracking purpose, so that, say, Vectors and Operators can carry their own memory pools built on CXL (or GPU) memory, or that we actually want operators to be able to spill across the memory hierarchy? My only concern with the latter is that the currently spill algorithms we support are likely tied to the memory<->SSD/disk concept, so I'm not sure they will translate to other memory hierarchies. Meaning it would likely require different spilling strategies to begin with, and these are not very self-contained today. But it would be interesting to understand what these are. |
|
I'm waiting for a consensus on this. Meanwhile I implemented the proposal in my fork. Let me know if I can make a PR. |
Uh oh!
There was an error while loading. Please reload this page.
1. Motivation
Velox's current memory management assumes that CPU DRAM is the only resource to be managed. With heterogeneous compute extensions like the cuDF integration, this assumption no longer holds: GPUs introduce their own memory, and emerging tiered memory technologies like CXL introduce additional resources with distinct latency and bandwidth characteristics. Today the cuDF extension's GPU memory allocations are unaccounted and invisible to the rest of the engine.
One could make Velox transparently spill from a fast resource to a slow one (e.g., GPU → host DRAM). However, transparent spilling across tiers introduces hard-to-diagnose performance regressions, because the access-latency cliff between tiers is large and the spill point is invisible to the operator that triggered it. This proposal takes the position that which resource a given allocation lands on is a first-class scheduling decision, not something the system should make implicitly.
2. Goal
Allow
MemoryManagerto host multiple memory resources side-by-side, where each resource carries its own allocator and its own arbitrator. An extension should be able to register a new resource by supplying a single object that bundles three things: a tag, an allocator, and an arbitrator. A single registration entry feels right because the three are logically coupled — an arbitrator manages capacity over a specific allocator's address space, and the tag is what pools use to opt into that resource.The current code path must continue to work unchanged when no extension registers a custom resource.
Out of scope for this proposal:
3. Design Sketch
The shape we have in mind follows
DriverAdapter. The idea is to extend pluggability to the allocator side and bundle allocator + arbitrator under one registration entry.CustomMemoryResource
The extension would construct the allocator and arbitrator with whatever configuration it needs, then hand the bundle to
MemoryManager:Example end-to-end usage
4. Open Questions
4.1 How should we handle query failure?
Maybe I should look more into this but as QueryCtx now knows custom memory pools and the memory reclaimers, we can iterate over them to reclaim outstanding memory. I'm wondering if there would be any order preservation needed when we reclaim memory resources.
4.2 Where should we draw the scope of this project if we proceed?
I think I could plumb through the frameworks with unit tests and the mock custom memory resources. Then, I guess it's the extension developer's turns to implement the custom memory resource for their extensions.
Please review the proposal and tell me if there are things I need to consider before start working.
Best regards,
Sungwoo
All reactions