dferstay commented on a change in pull request #694:
URL: https://github.com/apache/pulsar-client-go/pull/694#discussion_r776848134
##########
File path: pulsar/default_router.go
##########
@@ -80,32 +79,27 @@ func NewDefaultRouter(
// spread the data on different partitions but not necessarily
in a specific sequence.
var now int64
size := uint32(len(message.Payload))
- previousMessageCount := atomic.LoadUint32(&state.msgCounter)
- previousBatchingMaxSize :=
atomic.LoadUint32(&state.cumulativeBatchSize)
- previousLastChange :=
atomic.LoadInt64(&state.lastChangeTimestamp)
+ messageCount := atomic.AddUint32(&state.msgCounter, 1)
+ batchSize := atomic.AddUint32(&state.cumulativeBatchSize, size)
- messageCountReached := previousMessageCount >=
uint32(maxBatchingMessages-1)
- sizeReached := (size >=
uint32(maxBatchingSize)-previousBatchingMaxSize)
+ messageCountReached := messageCount%uint32(maxBatchingMessages)
== 0
Review comment:
Updated parellel bench results before and after this commit:
```
name old time/op new time/op delta
DefaultRouterParallel 14.7ns ± 1% 14.9ns ± 6% ~ (p=0.248 n=9+9)
DefaultRouterParallel-2 55.0ns ±13% 33.7ns ± 8% -38.71% (p=0.000 n=10+9)
DefaultRouterParallel-4 53.5ns ± 9% 28.8ns ± 4% -46.13% (p=0.000 n=10+9)
DefaultRouterParallel-8 54.2ns ± 8% 36.3ns ± 1% -33.04% (p=0.000 n=10+8)
DefaultRouterParallel-16 56.4ns ±21% 39.5ns ±21% -29.98% (p=0.000
n=10+10)
```
--
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]