Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1510047
commit 0aec0ee
Showing
3 changed files
with
35 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
# Copy html5jp JavaScript codes to public/javascripts. | ||
|
||
Dir.chdir(File.join(RAILS_ROOT, 'vendor', 'plugins', 'html5jp_graphs')) do | ||
dest_dir = File.join(RAILS_ROOT, 'public', 'javascripts') | ||
FileUtils.mkdirs(dest_dir) unless File.exist?(dest_dir) | ||
dest_dir = File.join(RAILS_ROOT, 'public', 'javascripts') | ||
FileUtils.mkdirs(dest_dir) unless File.exist?(dest_dir) | ||
|
||
Dir.glob("html5jp/html5jp/**/*.js").each do |path| | ||
FileUtils.cp(path, dest_dir) unless File.exist?(File.join(dest_dir, File.basename(path))) | ||
end | ||
Dir.glob(File.join(RAILS_ROOT, File.dirname(__FILE__), "html5jp/html5jp/**/*.js")).each do |path| | ||
FileUtils.cp(path, dest_dir) unless File.exist?(File.join(dest_dir, File.basename(path))) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0aec0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only reference I've seen to
ObjectSpace.count_object_lifetimes
. Is it a custom extension? What does it measure?0aec0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The patch of
ObjectSpace.count_object_lifetimes
is here.https://gist.github.com/79030
This method returns
{T_XXX => 'Average GC count of a T_XXX object', T_XXX => ...}
. But, I didn't commit to Ruby's trunk because GC was slightly slow by this patch.0aec0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you -- this is very useful! It doesn't seem much slower, either.
I'd be happy to trade some performance for greater knowledge about the live objects in the heap.
0aec0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'll propose a method that is like this to ML :)
I have one question. Do you have any use-case for this method?
e.g. finding some memory leaks...
0aec0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. For example, we can look for leaks by watching growth of
ObjectSpace.count_object_lifetimes[:T_ARRAY] / Object.count_objects[:T_ARRAY]
A histogram of object lifetimes would be even more useful. Split lifetimes into buckets (log scale) and count objects in each bucket. That gives an even clearer picture of object churn (generating temporary garbage) versus long-lived objects (loaded Ruby code, singletons, loaded YAML) versus leaks (unbounded cache, stray references to temporary objects) and show how they change over time.
Then leaks would show up as increasing numbers of aging objects.
0aec0ee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, this histogram is useful! Thanks for your idea!