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

Do we need a mutex in FieldMap ? #677

Open
sylr opened this issue Oct 24, 2024 · 1 comment
Open

Do we need a mutex in FieldMap ? #677

sylr opened this issue Oct 24, 2024 · 1 comment

Comments

@sylr
Copy link
Contributor

sylr commented Oct 24, 2024

In #485 a mutex has been added to FieldMap to make it Thread Safe.

However, in the same PR, the Message pool mechanism has also been removed so Messages are not re-used any longer and it's up to the Go garbage collector to free unused messages.

In that context I fail to see a scenario where a Message and the underlying FieldMaps need to be thread safe.

Can someone share a use case where a message is concurrently read/updated ?

cc @waheedoo @ackleymi

@matejsp
Copy link

matejsp commented Dec 18, 2024

I was asking myself the same question. We got bitten by slow reads from parsed message since every field is protected mutex lock slowing down the processing.
I would prefer no locking of messages especially if they are no longer reused.

If you need to lock the FieldMap you should do it outside in your own code (this would also improve when getting or setting multiple fields).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants