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

Add log.singletons and .verbose to track singleton class creation. #5515

Merged
merged 1 commit into from Dec 13, 2018

Conversation

@headius
Copy link
Member

@headius headius commented Dec 13, 2018

Singleton objects, usually created via extend or def obj.meth,
frequently waste CPU cycles and memory. It's also easy to
accidentally trigger an object to become a singleton. These
properties will make it easy to track all singleton classes
created by an application, along with an optional stack trace.

Singleton objects, usually created via `extend` or `def obj.meth`,
frequently waste CPU cycles and memory. It's also easy to
accidentally trigger an object to become a singleton. These
properties will make it easy to track all singleton classes
created by an application, along with an optional stack trace.
@headius headius added this to the JRuby 9.2.6.0 milestone Dec 13, 2018
@headius headius requested review from kares and enebo Dec 13, 2018
@headius
Copy link
Member Author

@headius headius commented Dec 13, 2018

@guizmaii This is the flag I was mentioning. Run JRuby with -Xlog.singletons or -Xlog.singletons.verbose or add jruby. to the beginning of those and set them as JVM properties.

@kares
Copy link
Member

@kares kares commented Dec 13, 2018

loos good - hopefully real-world (app) usable as well ... seems like it would be, back-trace makes it so

@headius
Copy link
Member Author

@headius headius commented Dec 13, 2018

@kares Yeah I think it will be useful. If we see tons of new singleton classes being created long after an app has booted up, that's a red flag. We can flip the verbose flag and see where it's happening.

I am only logging the JVM trace here, though...perhaps I should log a "full" trace with interpreted Ruby frames intact? It's going to be LONG either way.

@enebo enebo merged commit 0e32022 into jruby:master Dec 13, 2018
1 check failed
1 check failed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@enebo
Copy link
Member

@enebo enebo commented Dec 13, 2018

since kares also looked at this I just merged since I see no issues with this and think it will be useful

@headius headius deleted the headius:log_singletons branch Dec 13, 2018
@guizmaii
Copy link

@guizmaii guizmaii commented Dec 13, 2018

How can I test this ?

Is is something easy to compile locally JRuby and then use this locally compiled version ?

@headius
Copy link
Member Author

@headius headius commented Dec 13, 2018

@guizmaii Yes, check out my branch (headius/jruby) and you can build and use it. Alternatively you can pick it up from nightly builds (https://www.jruby.org/nightly)

@guizmaii
Copy link

@guizmaii guizmaii commented Dec 13, 2018

Ok thanks @headius. I'll try with the nightly builds I think :)

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

Successfully merging this pull request may close these issues.

None yet

4 participants