Skip to content

Commit

Permalink
[party] Better tail add participant costs (grpc#37055)
Browse files Browse the repository at this point in the history
Built on grpc#37038 which should be merged first

Closes grpc#37055

COPYBARA_INTEGRATE_REVIEW=grpc#37055 from ctiller:no-after-4 55d91cc
PiperOrigin-RevId: 647761845
  • Loading branch information
ctiller authored and copybara-github committed Jun 28, 2024
1 parent 2431805 commit b489c2c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/core/lib/promise/party.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,12 @@ class PartySyncUsingAtomics {
do {
wakeup_mask = 0;
allocated = (state & kAllocatedMask) >> kAllocatedShift;
size_t n = 0;
for (size_t bit = 0; n < count && bit < party_detail::kMaxParticipants;
bit++) {
if (allocated & (1 << bit)) continue;
wakeup_mask |= (1 << bit);
slots[n++] = bit;
allocated |= 1 << bit;
for (size_t i = 0; i < count; i++) {
auto new_mask = LowestOneBit(~allocated);
wakeup_mask |= new_mask;
allocated |= new_mask;
slots[i] = CountTrailingZeros(new_mask);
}
CHECK(n == count);
// Try to allocate this slot and take a ref (atomically).
// Ref needs to be taken because once we store the participant it could be
// spuriously woken up and unref the party.
Expand Down

0 comments on commit b489c2c

Please sign in to comment.