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

Back VirtualField with a volatile field #4269

Closed
trask opened this issue Oct 2, 2021 · 3 comments · Fixed by #4355
Closed

Back VirtualField with a volatile field #4269

trask opened this issue Oct 2, 2021 · 3 comments · Fixed by #4355
Assignees
Labels
enhancement New feature or request

Comments

@trask
Copy link
Member

trask commented Oct 2, 2021

Tracking issue for discussion item raised in #4262 (comment)

Backing with a volatile field is definitely the safest, but it may also be nice to have the option to back it with a non-volatile field in specific places where we know that's safe.

@mateuszrzeszutek
Copy link
Member

but it may also be nice to have the option to back it with a non-volatile field in specific places where we know that's safe.

Are performance gains that come from the field being non-volatile really so significant? Allowing to choose the synchronization model (volatile vs not volatile) when retrieving the field would probably really complicate the already complex VirtualField API and implementation (especially implementation).

@anuraaga
Copy link
Contributor

anuraaga commented Oct 4, 2021

As with many things, they "can" be very significant. That being said, do we have obvious patterns where non-volatile is OK? I think propagating context is the most common use of virtual field, and this naturally needs to be volatile as it involves multiple threads. Went through a few pages of search results, and I suspect 90+% of usages of VirtualField have the word Context or Async in the value type, I saw a Span (which should probably be Context :O). Exceptions include

  • DbInfo - I guess JDBC connection can be read from a different thread when there is a connection pool used form a threadpool like in HikariCP
  • Boolean - to verify whether a gRPC resource has already been instrumented or not. There's no performance impact since these are only supposed to be called once / few times per app, not on hot path, due to being innately slow operations.

Didn't dig through all usages, but volatile-only seems to be reasonable to me.

@trask
Copy link
Member Author

trask commented Oct 4, 2021

Are performance gains that come from the field being non-volatile really so significant?

it may be early for us to be tackling volatile fields, but I did find it helpful when pushing performance in glowroot

depending on specifics, sometimes the needed visibility memory barriers are provided by writing/reading from an execution queue or object pool (unless i'm wrong, which is entirely possible, this stuff is hard)

volatile-only seems to be reasonable to me

👍

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

Successfully merging a pull request may close this issue.

3 participants