dferstay commented on a change in pull request #684:
URL: https://github.com/apache/pulsar-client-go/pull/684#discussion_r775298110
##########
File path: pulsar/default_router.go
##########
@@ -30,6 +31,7 @@ type defaultRouter struct {
lastChangeTimestamp int64
msgCounter uint32
cumulativeBatchSize uint32
+ sync.RWMutex
Review comment:
@zzzming , I've attempted to address the races when updating the default
router state in a lock-free manner here: Please take a look and see if you are
satisfied: https://github.com/apache/pulsar-client-go/pull/694
Comparing the results from the parallel default router bench test we can see
that the use of a mutex has an impact on performance (old==this PR,
new==https://github.com/apache/pulsar-client-go/pull/694):
```
name old time/op new time/op delta
DefaultRouterParallel 27.4ns ± 3% 14.8ns ± 2% -45.79% (p=0.000 n=10+8)
DefaultRouterParallel-2 35.2ns ± 1% 41.9ns ± 0% +18.96% (p=0.000 n=9+7)
DefaultRouterParallel-4 49.4ns ± 6% 44.1ns ± 8% -10.84% (p=0.000 n=10+9)
DefaultRouterParallel-8 58.8ns ± 6% 53.2ns ± 3% -9.53% (p=0.000 n=10+8)
DefaultRouterParallel-16 69.7ns ± 3% 51.3ns ± 0% -26.43% (p=0.000 n=10+8)
```
EDIT: I can't explain why `DefaultRouterParallel-2` is slower on the branch
that doesn't use the mutex.
--
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]