wwbmmm commented on PR #3144:
URL: https://github.com/apache/brpc/pull/3144#issuecomment-7121680075

   I agree with the analysis and the direction: putting device blocks into 
IOBuf changes its contract (copy_to()/to_string()/size() and every existing 
consumer assume host memory, and is_gpu_memory() only inspects the first block, 
which is not enough for mixed buffers). That semantic change is the root cause 
of the long tail of findings in this PR (CRC32C, rpc_dump, 
baidu_master_service, mixed-buffer handling). A first-class device attachment 
is the cleaner design, and I would support it. A few points need to be nailed 
down before implementation: 
   
   1. Ownership and lifetime. Define precisely who owns the device ranges and 
how long bRPC holds a reference. On send, the caller registers the memory (or 
hands over an already-registered region) and bRPC must keep it alive until the 
NIC reports completion for the WQE that reads it; on receive, bRPC owns the 
pool block and the application must hold a reference while it consumes the 
data, otherwise block reuse races with the application's CUDA work. Please 
state whether request_device_attachment() returns a borrowed view over bRPC's 
pool block or caller-owned registered memory, and make the two distinguishable. 
   2. Wire compatibility. device_attachment_size changes the body layout, so a 
peer that does not understand it must never see it. This needs explicit 
capability negotiation (a flag in the RDMA handshake or a capability bit in the 
request meta) and must be a hard error if a device section arrives on a 
connection that did not negotiate it, not a silent fallback. Also make sure the 
device section is included in body_size so that old parsers reject the frame 
cleanly instead of mis-parsing the remainder as attachment/body. 
   3. Semantics. Confirm and document that device bytes bypass parsing, 
compression and CRC32C, and that checksum_with_attachment still covers only the 
host attachment; the receiver should reject a device section it cannot consume 
rather than deliver it half-validated. 
   4. Scope. This is a substantial redesign, and it restarts review of a large 
PR that has just reached a green, tested state. To keep the transport work that 
is independent of this issue (GPU block pool, GDR handshake/block-size 
negotiation, TCP fallback, bazel/cmake plumbing, endpoint lifecycle), I would 
suggest splitting: land the transport/pool/handshake part first (it does not 
change IOBuf's contract), and implement DeviceAttachment + the baidu_std device 
section as a follow-up PR. Attachments as they exist today would keep working 
over GDR by copying to host in the interim, or GDR could be limited to 
header/meta/body until the follow-up lands. In short: yes, keeping device 
memory out of IOBuf is the right long-term shape; my main asks are explicit 
lifetime rules, negotiated protocol capability, and splitting the PR so the 
already-validated transport work is not held hostage by the redesign.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to