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

Symbol GC - Ruby 2.2.0 compatibility #2350

Closed
rjnienaber opened this issue Dec 27, 2014 · 5 comments
Closed

Symbol GC - Ruby 2.2.0 compatibility #2350

rjnienaber opened this issue Dec 27, 2014 · 5 comments

Comments

@rjnienaber
Copy link

@rjnienaber rjnienaber commented Dec 27, 2014

I've copied the code from the original patch in MRI (#9634) and run it against JRuby HEAD (c1be61a) and it seems that Symbols are not getting GC'ed. I'm not sure if this is classified as an implementation detail but I would think this might have some impact for Rails 5.0 when it comes out. Here's the code:

obj = Object.new
100_000.times do |i|
  obj.respond_to?("sym#{i}".to_sym)
end
GC.start
puts"symbol : #{Symbol.all_symbols.size}"

Here's the results:

$ rvm 2.2.0 do ruby -v gc_patch.rb 
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin14]
symbol : 2505
$ rvm jruby-head do ruby -v gc_patch.rb 
jruby 9.0.0.0-SNAPSHOT (2.2.0p0) 2014-12-27 c1be61a Java HotSpot(TM) 64-Bit Server VM 25.5-b02 on 1.8.0_05-b13 +jit [darwin-x86_64]
symbol : 100977
@Ch4s3
Copy link

@Ch4s3 Ch4s3 commented Dec 27, 2014

+1

@kares
Copy link
Member

@kares kares commented Dec 28, 2014

test is pretty naive, considering there's enough memory 100_000 objects might not simply fill it up ... also GC.start in JRuby does not come with a guarantee that GC has actually run and/or reclaimed all trash.

@rjnienaber
Copy link
Author

@rjnienaber rjnienaber commented Dec 28, 2014

According to this post by @headius, GC.start is stubbed out because some code will call it unnecessarily on JRuby. I modified the code to use System.gc and then added log lines before and after the request and I got these results:

rvm jruby-head do ruby -J-verbose:gc -J-XX:+PrintGCTimeStamps -J-XX:+PrintGCDetails -v gc_patch.rb 
<snip />
Request Garbage Collection
5.907: [GC (System.gc()) [PSYoungGen: 16408K->8608K(28160K)] 51133K->49460K(72704K), 0.0347450 secs] [Times: user=0.10 sys=0.01, real=0.03 secs] 
5.942: [Full GC (System.gc()) [PSYoungGen: 8608K->1804K(28160K)] [ParOldGen: 40852K->44437K(44544K)] 49460K->46241K(72704K), [Metaspace: 26143K->26143K(1071104K)], 0.4640830 secs] [Times: user=1.37 sys=0.01, real=0.47 secs] 
Finish requesting Garbage Collection

symbol : 100979

It would appear that a Full GC has been run.

@enebo enebo added this to the JRuby 9.0.0.0 milestone Dec 29, 2014
@enebo
Copy link
Member

@enebo enebo commented Dec 29, 2014

We need to change our symbol backing store to not keep hard references. We were aware that this is an unfinished task but i think we must have missed filing a tracking issue for this.

@enebo enebo added this to the JRuby 9.0.0.0-pre1 milestone Dec 30, 2014
@enebo enebo removed this from the JRuby 9.0.0.0 milestone Dec 30, 2014
@headius
Copy link
Member

@headius headius commented Dec 30, 2014

Easier than expected...fixed in f777300.

@headius headius closed this Dec 30, 2014
@kares kares mentioned this issue Jan 12, 2015
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

5 participants