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

Move ObjectSpace#each_object to a JVM agent #8073

Open
headius opened this issue Jan 20, 2024 · 1 comment
Open

Move ObjectSpace#each_object to a JVM agent #8073

headius opened this issue Jan 20, 2024 · 1 comment

Comments

@headius
Copy link
Member

headius commented Jan 20, 2024

Currently we still have all the endpoints and checks in places for ObjectSpace.each_object, even if it is not enabled. This adds a small amount of overhead to most object allocations.

Since we require users to turn on the each_object functionality, we could at that point load an agent into the JVM that has access to debugging APIs, and use those APIs to provide the heap walking.

Work would need to be done to find the most efficient way to walk all heap objects.

My previous prototypes used the Java Debug Interface to loop over objects and update a separately-executing thread's active frame so it would see each object in turn. It worked, but was incredibly slow. An approach that instruments object construction and used the current weak map logic would be possible through an agent.

@headius headius added this to the JRuby 9.5.0.0 milestone Jan 20, 2024
@headius
Copy link
Member Author

headius commented Jun 4, 2024

This is more complicated than it seems due to the ability to turn on ObjectSpace.each_object at runtime via JRuby::Util.object_space=. I've got code in #8279 to officially deprecate that, but I'm unsure how frequently it might be used in the wild.

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

1 participant