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

Ruby 3.2 support - Report on the new VM's :constant_cache stat instead of the old :global_constant_state #1059

Closed
fallwith opened this issue Apr 4, 2022 · 7 comments · Fixed by #1436

Comments

@fallwith
Copy link
Contributor

fallwith commented Apr 4, 2022

As per Ruby PR #5433, which satisfies feature #18589, the CRuby VM now provides finer grained control over the constants cache.

For Ruby 2.1.0 through 3.1.x, the Ruby agent has been making use of RubyVM.stat[:global_constant_state] to tally up cache invalidations (see: lib/new_relic/agent/vm/mri_vm.rb).

For Ruby 3.2+, the RubyVM.stat hash no longer has a :global_constant_state key. Instead it now has a :constant_cache key, and a hash as the corresponding value. That inner hash keeps track of cache on a per constant basis, with the constants themselves serving as the inner hash keys.

My current guess is that we need to replace the existing call to RubyVM.stat[:global_constant_state] with something like RubyVM.stat[:constant_cache].values.sum, but I have not taken the time yet to thoroughly research the RubyVM change that took place.

@fallwith fallwith added the feature request To tag feature request after Hero Triage for PM to disposition label Apr 4, 2022
@angelatan2 angelatan2 added this to the Support of Ruby 3.2 milestone Apr 4, 2022
@fallwith
Copy link
Contributor Author

Update - PR #1088 delivers a backwards compatibility fix to ensure that Ruby 3.2 works with the existing way of reporting a single integer value to represent all constant cache invalidations.

This issue will be left open to track efforts to consider / implement support for the new fine grained metrics themselves. The new hash can get pretty big (every Ruby constant gets a key) so reporting on the entire hash as option as we report VM metrics might not be a good idea.

@kaylareopelle kaylareopelle removed the feature request To tag feature request after Hero Triage for PM to disposition label Aug 16, 2022
@workato-integration
Copy link

@fallwith
Copy link
Contributor Author

Ruby PR 5715 delivered Ruby 69967ee6 and reverted the change.

Then Ruby PR 5766 came along and again removed the :global_constant_state VM stat key and replaced it with 2 new keys: :constant_cache_invalidations and
:constant_cache_misses.

fallwith added a commit that referenced this issue Sep 15, 2022
* Start using Ruby 3.2.0-preview2 for CI
* Support Ruby 3.2's two separate VM stats,
  `:constant_cache_invalidations` and `:constant_cache_misses`.

Prior to Ruby 3.2, Ruby offered a `:global_constant_state` VM stat that
the New Relic Ruby agent used to report on constant cache invalidations.

Ruby 3.2 offers improved statistics for constants and has replaced
`:global_constant_state` with 2 new attributes,
`:constant_cache_invalidations` and `:constant_cache_misses`. The New
Relic Ruby agent will use `:constant_cache_invalidations` for its
existing reporting of invalidations and will also start to report on
constant cache misses when Ruby 3.2+ is present.

Resolves #1059
@workato-integration
Copy link

Work has been completed on this issue.

3 similar comments
@workato-integration
Copy link

Work has been completed on this issue.

@workato-integration
Copy link

Work has been completed on this issue.

@workato-integration
Copy link

Work has been completed on this issue.

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

Successfully merging a pull request may close this issue.

3 participants