dferstay opened a new pull request #319: URL: https://github.com/apache/pulsar-client-go/pull/319
Passing a function parameter by pointer (or writing a pointer into a channel) will cause the Go escape analysis to allocate the parameter on the heap. This change passes messageID struct instances by value instead of by pointer; this keeps messageID structs on the stack. Each message produced or consumed by the library is associated with a MessageID; keeping instances of the MessageID structure on the stack reduces heap allocation and associated GC cost. Signed-off-by: Daniel Ferstay <[email protected]> ### Motivation Reduce the amount of per-Message heap allocation performed by the library ### Modifications This change modifies the Consumer and Producer code paths to pass messageID struct instances by value instead of by pointer; this keeps the messageID structures on the stack and off of the heap. ### Verifying this change - [ ] Make sure that the change passes the CI checks. This change is already covered by existing tests, such as: * pulsar/consumer_multitopic_test.go * pulsar/consumer_partition_test.go * pulsar/consumer_regex_test.go * pulsar/consumer_test.go * pulsar/impl_message_test.go * pulsar/negative_acks_tracker_test.go * pulsar/producer_test.go * pulsar/reader_test.go ### Does this pull request potentially affect one of the following parts: - Dependencies (does it add or upgrade a dependency): no - The public API: no - The schema: no - The default values of configurations: no - The wire protocol: no ### Documentation - Does this pull request introduce a new feature? no ---------------------------------------------------------------- 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: [email protected]
