chenBright opened a new pull request, #3541:
URL: https://github.com/apache/brpc/pull/3541

   ### What problem does this PR solve?
   
   Issue Number: resolve 
   
   Problem Summary:
   
   `TaskGroup` tracks per-group CPU time as a 128-bit stat (a packed
     `last_run_ns` + task-type word and a `cumulated_cputime_ns` word) that a
     worker updates while other threads (e.g. bvar sampling) read it
     concurrently. This was implemented with `AtomicInteger128`, whose 128-bit
     "atomic" load/store had no portable, guaranteed lock-free backing:
   
     - On x86 it relied on wide SSE/AVX aligned loads/stores being atomic. This 
is 
        not guaranteed by the ISA, because Intel and AMD do not officially 
promise 128-bit 
        AVX load/store atomicity. It merely happens to hold on current 
microarchitectures 
        (Skylake, Zen 2). Depending on it is relying on unspecified hardware 
behavior.
     - On platforms without such a wide atomic it fell back to a mutex, which 
serializes 
        readers and blocks them behind the writer. Exactly what a 
consistent-snapshot 
        read is meant to avoid.
   
   ### What is changed and the side effects?
   
   Changed:
   
     - Add `butil::Seqlock`, a general sequence lock providing lock-free, 
consistent snapshot 
        reads around a caller-owned atomic payload.
     - Replace `TaskGroup::AtomicInteger128` with an `AtomicCPUTimeStat` backed 
by 
        `butil::Seqlock<>` over a `CPUTimeStat` payload accessed via relaxed 
atomics.
   
   Side effects:
   - Performance effects:
   
   - Breaking backward compatibility: 
   
   ---
   ### Check List:
   - Please make sure your changes are compilable.
   - When providing us with a new feature, it is best to add related tests.
   - Please follow [Contributor Covenant Code of 
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).


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