Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it safe to reuse value from AsyncProducer.Successes() #1302

Closed
abonec opened this issue Mar 7, 2019 · 6 comments
Closed

Is it safe to reuse value from AsyncProducer.Successes() #1302

abonec opened this issue Mar 7, 2019 · 6 comments
Labels
question stale Issues and pull requests without any recent activity

Comments

@abonec
Copy link

abonec commented Mar 7, 2019

Is it safe to reuse value from AsyncProducer.Successes() to next messages? Due to lack of documentation in the code it is not clear.
Need to clarify it in the doc.

@varun06
Copy link
Contributor

varun06 commented Mar 7, 2019

Can you please elaborate more and give a quick use case?

@abonec
Copy link
Author

abonec commented Mar 10, 2019

My messages in megabytes and I want to check AsyncProducer.Successes and put those slices to sync.Pool to reuse later in order to reduce pressure to GC.

@varun06
Copy link
Contributor

varun06 commented Mar 10, 2019

More curious - First of all, sync.Pool gets cleared every GC cycle, so you should use it very carefully, but I am more curious about your storing messages from success and doing something with them, can you tell me more about your use case?

@abonec
Copy link
Author

abonec commented Mar 10, 2019

Ok. My algorithm as following:
Send loop:

  1. Take []byte from the sync.Pool
  2. Serialize (size of slice counts in megabytes) message to this slice
  3. Produce this message via async producer.

Release loop:

  1. Get sent message from the AsyncProducer.Successes
  2. Put underlying slice back to the pool to serialize next message.

My question is:
Is it safe to reuse []byte to future serialization? I ask because there will be serious issue if there will be concurrent write to this slice between sarama and my code.

@ghost
Copy link

ghost commented Feb 21, 2020

Thank you for taking the time to raise this issue. However, it has not had any activity on it in the past 90 days and will be closed in 30 days if no updates occur.
Please check if the master branch has already resolved the issue since it was raised. If you believe the issue is still valid and you would like input from the maintainers then please comment to ask for it to be reviewed.

@ghost ghost added the stale Issues and pull requests without any recent activity label Feb 21, 2020
@ghost ghost closed this as completed Mar 22, 2020
@vincentbernat
Copy link
Contributor

This question is quite interesting. Does someone has an answer for it?

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question stale Issues and pull requests without any recent activity
Projects
None yet
Development

No branches or pull requests

4 participants