Skip to content

Reduce volatile reads in Metadata.LazyValue#toBytes#12617

Open
kilink wants to merge 1 commit intogrpc:masterfrom
kilink:double-checked-locking-metadata
Open

Reduce volatile reads in Metadata.LazyValue#toBytes#12617
kilink wants to merge 1 commit intogrpc:masterfrom
kilink:double-checked-locking-metadata

Conversation

@kilink
Copy link
Contributor

@kilink kilink commented Jan 20, 2026

Fix double-checked locking idiom and reduce volatile reads in Metadata.LazyValue#toBytes.

Fix double-checked locking idiom and reduce volatile reads in Metadata.LazyValue#toBytes.
@kannanjgithub
Copy link
Contributor

Volatile reads are very fast, often nearly as fast as normal variable reads on most modern computer architectures, and in any case are likely cause problem only in a tight loop with high contention which is not the usage here.
Volatile write has a higher cost than volatile read and since we are okay with the write itself, read should not be a bother.
In general also we try to refrain from tweaking code that is working fine without any problems for years / decades.

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

Successfully merging this pull request may close these issues.

2 participants