You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/05/14 02:13:23 UTC

[GitHub] [pulsar-client-go] rueian commented on a change in pull request #247: [Issue 246][compression.Provider] Not sharing compression.Provider among producers and consumers

rueian commented on a change in pull request #247:
URL: https://github.com/apache/pulsar-client-go/pull/247#discussion_r424831944



##########
File path: pulsar/consumer_partition.go
##########
@@ -875,6 +868,20 @@ func (pc *partitionConsumer) discardCorruptedMessage(msgID *pb.MessageIdData,
 		})
 }
 
+func (pc *partitionConsumer) getCompressionProvider(compressionType pb.CompressionType) (
+	provider compression.Provider, ok bool) {
+	if pc.compressionProviders == nil {
+		pc.compressionProviders = map[pb.CompressionType]compression.Provider{

Review comment:
       Not all providers are thread safe. For example currently the zstdProvider reusing its encoder when calling `Compress(data)`. Therefore I think each consumer and each producer should have their own set of compression providers to avoid racing on the global shared providers. And yes, it will have overhead.
   
   Yes, preallocating will make the code here simpler, I will change that.
   




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org