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

[Truffle] Add tools for measuring startup time and memory consumption. #3296

Merged
merged 7 commits into from
Sep 1, 2015

Conversation

chrisseaton
Copy link
Contributor

@pitr-ch @eregon @nirvdrum please review

@chrisseaton chrisseaton self-assigned this Aug 28, 2015
@chrisseaton chrisseaton added this to the truffle-dev milestone Aug 28, 2015
max_iterations = 100

lower = 0
upper = 4 * 1024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 4 * 1024?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just an initial size that was bound to be big enough. But now I think about it I can also search for the upper bound and not have one hard coded. I'll do that.

@eregon
Copy link
Member

eregon commented Aug 29, 2015

Looks good.
My initial thought was to do sth like printTime("next step name") + one printTime("END") at the end so there is no need for before/after pair and it's easier to make sure everything is counted overall. But this does not support nesting so this PR approach seems better.

@chrisseaton
Copy link
Contributor Author

@smarr please review if you have the time (especially https://github.com/jruby/jruby/pull/3296/files#diff-1c0dfa12324db9c68111f81e23be1ee6R1)


private static void printTruffleMemoryMetric() {
if (Options.TRUFFLE_METRICS_MEMORY_USED_ON_EXIT.load()) {
System.gc();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be problematic for multiple reasons.

Haven't yet read further in the changes, but, you are in the main method, and do a GC. So, I would expect, if there is no static state/memory leaks, after this GC, the used memory should be 0.
So, you might want to get the heap usage before the GC.

Also, System.gc() is really just a hint on HotSpot, you have to call it 3-4 times in succession to motivate HotSpot to actually do a collect (but, this then usually works).

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I now saw that you parse verbose:gc, nice. Ok, but you probably still want to call System.gc() multiple times to make sure it triggers. Then, I would assume that the verbose:gc output gives you a sum of all the objects that made it into GCed memory.

Looks good to me!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JRuby has a great deal of static state (even though it is actually re-entrant) so I still need to check heap usage right at the end. Now I think about it I'm not sure what the point is of the GC at the end, given that I need to check heap usage after it anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side note: there may be a reliable way how to force gc in JVMTI, http://docs.oracle.com/javase/7/docs/platform/jvmti/jvmti.html#ForceGarbageCollection. I did not use it though.

chrisseaton added a commit that referenced this pull request Sep 1, 2015
[Truffle] Add tools for measuring startup time and memory consumption.
@chrisseaton chrisseaton merged commit eb79c9b into master Sep 1, 2015
@chrisseaton chrisseaton deleted the truffle-metrics branch September 1, 2015 12:46
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
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.

None yet

6 participants