lh2debug commented on PR #3140:
URL: https://github.com/apache/brpc/pull/3140#issuecomment-3501682350

   1. In LocalStorage, `rpcz_parent_span` maintains a `void*` type. The span 
layer provides functions to manage the `weak_ptr` pointer using `new`/`delete` 
and assign it to `rpcz_parent_span`. I've considered and tested this approach, 
and it seems feasible.
   
   2. Regarding the method of embedding reference counting within the span:
   
   1) It's more complex in principle and implementation than the smart pointer 
method. Imagine a Raft scenario: one server span creates two bthreads. Each 
bthread context initiates an RPC (i.e., creates a client span). That is, the 
server span is the parent of the bthread span, and the bthread span is the 
parent of the client span. In this case, manually adding references/releasing 
references to the server span, bthread span, and client span is much more 
complex than the smart pointer method.
   
   2) It's not flexible enough for business trace collection. For example, if 
the business wants to collect some trace information in a background thread 
outside the brpc context, the smart pointer method simply passes the `weak_ptr` 
as a function parameter to the function of that background thread. When the 
background thread wants to collect traces, it only needs to use `weak_ptr.lock` 
(if the lock succeeds, the collection is successful; if the lock fails, it 
means the RPC has ended and collection is no longer needed). Implementing this 
logic manually using reference counting is not easy (it requires elegant manual 
`add ref` and `release` operations).


-- 
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