Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notes: * Adds a single participant `AddParticipant` variant for this common case (per grpc#37056 which I'm abandoning) * Folds the `PartySyncUsingAtomics` class back into `Party`, removes the `PartySyncUsingMutex` class * Leverages this integration to find places where we're doing repeated CAS operations and folds them into single operations (for example an unlock/unref pair can be folded into a single CAS) * Also lowers some `CHECK` statements into `DCHECK` - which I think is appropriate given the performance sensitivity of this code * Adds code to deal with overflowing the number of participants added to a party -- for now we do a busy add by queuing to event engine and retrying -- this has the advantage of not adding cost to the normal path, but has the slightly worrying disadvantage of effectively being a busy poll. My expectation is that this will be ok in general (the condition clears very quickly), but if not we'll modify this to be a linked list of pending actions and take a hit on the fast path. * Simplifies `PartyIsOver` (per grpc#37113 which I'm abandoning) * Keeps a per-object wakeup cache (`wakeup_mask_`) that is protected by the lock bit -- this allows waking up a participant during polling without resorting to an extra atomic operation - significantly speeding that wakeup path (17ns --> 6ns) Before: ``` ---------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------- BM_PartyCreate 142 ns 142 ns 44952269 BM_PartyCreate 73.8 ns 73.8 ns 44952269 BM_PartyCreate 72.6 ns 72.6 ns 44952269 BM_PartyCreate 72.5 ns 72.5 ns 44952269 BM_PartyCreate 72.4 ns 72.4 ns 44952269 BM_PartyCreate 72.5 ns 72.5 ns 44952269 BM_PartyCreate 72.5 ns 72.5 ns 44952269 BM_PartyCreate 72.6 ns 72.6 ns 44952269 BM_PartyCreate 72.2 ns 72.2 ns 44952269 BM_PartyCreate 72.5 ns 72.5 ns 44952269 BM_PartyCreate_mean 79.5 ns 79.5 ns 10 BM_PartyCreate_median 72.5 ns 72.5 ns 10 BM_PartyCreate_stddev 21.8 ns 21.8 ns 10 BM_PartyCreate_cv 27.46 % 27.46 % 10 BM_AddParticipant 35.3 ns 35.3 ns 197041251 BM_AddParticipant 35.3 ns 35.3 ns 197041251 BM_AddParticipant 35.1 ns 35.1 ns 197041251 BM_AddParticipant 35.4 ns 35.4 ns 197041251 BM_AddParticipant 35.3 ns 35.3 ns 197041251 BM_AddParticipant 35.2 ns 35.2 ns 197041251 BM_AddParticipant 35.9 ns 35.9 ns 197041251 BM_AddParticipant 36.0 ns 36.0 ns 197041251 BM_AddParticipant 35.8 ns 35.8 ns 197041251 BM_AddParticipant 36.0 ns 36.0 ns 197041251 BM_AddParticipant_mean 35.5 ns 35.5 ns 10 BM_AddParticipant_median 35.4 ns 35.4 ns 10 BM_AddParticipant_stddev 0.352 ns 0.352 ns 10 BM_AddParticipant_cv 0.99 % 0.99 % 10 BM_WakeupParticipant 17.1 ns 17.1 ns 406116840 BM_WakeupParticipant 16.9 ns 16.9 ns 406116840 BM_WakeupParticipant 16.8 ns 16.8 ns 406116840 BM_WakeupParticipant 16.8 ns 16.8 ns 406116840 BM_WakeupParticipant 16.9 ns 16.9 ns 406116840 BM_WakeupParticipant 16.9 ns 16.9 ns 406116840 BM_WakeupParticipant 17.0 ns 17.0 ns 406116840 BM_WakeupParticipant 17.0 ns 17.0 ns 406116840 BM_WakeupParticipant 16.9 ns 16.9 ns 406116840 BM_WakeupParticipant 17.0 ns 17.0 ns 406116840 BM_WakeupParticipant_mean 16.9 ns 16.9 ns 10 BM_WakeupParticipant_median 16.9 ns 16.9 ns 10 BM_WakeupParticipant_stddev 0.087 ns 0.087 ns 10 BM_WakeupParticipant_cv 0.51 % 0.51 % 10 ``` After: ``` ---------------------------------------------------------------------- Benchmark Time CPU Iterations ---------------------------------------------------------------------- BM_PartyCreate 115 ns 115 ns 29602192 BM_PartyCreate 56.5 ns 56.5 ns 29602192 BM_PartyCreate 55.3 ns 55.3 ns 29602192 BM_PartyCreate 55.9 ns 55.9 ns 29602192 BM_PartyCreate 55.1 ns 55.1 ns 29602192 BM_PartyCreate 55.2 ns 55.2 ns 29602192 BM_PartyCreate 55.2 ns 55.2 ns 29602192 BM_PartyCreate 56.2 ns 56.2 ns 29602192 BM_PartyCreate 54.7 ns 54.7 ns 29602192 BM_PartyCreate 55.8 ns 55.8 ns 29602192 BM_PartyCreate_mean 61.5 ns 61.5 ns 10 BM_PartyCreate_median 55.5 ns 55.5 ns 10 BM_PartyCreate_stddev 18.9 ns 18.9 ns 10 BM_PartyCreate_cv 30.68 % 30.68 % 10 BM_AddParticipant 26.9 ns 26.9 ns 155407231 BM_AddParticipant 26.5 ns 26.5 ns 155407231 BM_AddParticipant 24.8 ns 24.8 ns 155407231 BM_AddParticipant 24.9 ns 24.9 ns 155407231 BM_AddParticipant 24.8 ns 24.8 ns 155407231 BM_AddParticipant 25.3 ns 25.3 ns 155407231 BM_AddParticipant 25.8 ns 25.8 ns 155407231 BM_AddParticipant 25.3 ns 25.3 ns 155407231 BM_AddParticipant 30.8 ns 30.8 ns 155407231 BM_AddParticipant 27.7 ns 27.7 ns 155407231 BM_AddParticipant_mean 26.3 ns 26.3 ns 10 BM_AddParticipant_median 25.6 ns 25.6 ns 10 BM_AddParticipant_stddev 1.87 ns 1.87 ns 10 BM_AddParticipant_cv 7.11 % 7.10 % 10 BM_WakeupParticipant 6.75 ns 6.75 ns 623459241 BM_WakeupParticipant 6.77 ns 6.77 ns 623459241 BM_WakeupParticipant 6.74 ns 6.74 ns 623459241 BM_WakeupParticipant 6.73 ns 6.73 ns 623459241 BM_WakeupParticipant 6.74 ns 6.74 ns 623459241 BM_WakeupParticipant 6.70 ns 6.70 ns 623459241 BM_WakeupParticipant 6.70 ns 6.69 ns 623459241 BM_WakeupParticipant 6.79 ns 6.79 ns 623459241 BM_WakeupParticipant 6.76 ns 6.76 ns 623459241 BM_WakeupParticipant 6.78 ns 6.78 ns 623459241 BM_WakeupParticipant_mean 6.75 ns 6.75 ns 10 BM_WakeupParticipant_median 6.75 ns 6.75 ns 10 BM_WakeupParticipant_stddev 0.031 ns 0.031 ns 10 BM_WakeupParticipant_cv 0.46 % 0.46 % 10 ``` Closes grpc#37132 COPYBARA_INTEGRATE_REVIEW=grpc#37132 from ctiller:nineteen-ninety-nine 336c87b PiperOrigin-RevId: 656437265
- Loading branch information