add optional gc constraint to config #433

Closed
dchelimsky opened this Issue Aug 5, 2011 · 20 comments

Projects

None yet
@dchelimsky
Member

Per http://www.rubyinside.com/careful-cutting-to-get-faster-rspec-runs-with-rails-5207.html

Something like:

RSpec.configure do |c|
  c.gc_frequency = 10
end

This would allow GC to run after every 10th example, allowing the user to set tweak the frequency per needs of each suite.

@justinko
justinko commented Aug 5, 2011

Cool!

@matellis
matellis commented Aug 5, 2011

+1

@cgriego
cgriego commented Aug 5, 2011

As a part of this, is it possible to ensure that the scheduled GC run time doesn't get added to the execution time calculated for the last example that ran? That's what has turned me off from using this technique in the past since fast examples would be blamed for being slow when it was just the deferred GC execution, making the --profile significantly less useful.

@dchelimsky
Member

@criego that would make this prohibitively complex in my view.

@MrJoy
MrJoy commented Aug 7, 2011

It shouldn't be a huge deal to just wrap the enable/start/disable calls in timestamp fetches, and accumulate (after-before) into a gc_time car that's subtracted from the total time and shown separately at the end, no?

@dchelimsky
Member

@MrJoy - I'm skeptical. Feel free to offer up a patch and we can talk about it.

@cgriego
cgriego commented Aug 7, 2011

If the ruby runtime supports GC stats, that could be used.

@logankoester

+1

@rizwanreza

+1

@adriancowham

+1

@speedmax

+1

@tbor
tbor commented Nov 14, 2011

+1

@ldenman
ldenman commented Dec 15, 2011

+1

@tmac
tmac commented Jan 17, 2012

+1

@dchelimsky
Member

Anybody care to submit a patch that adds this and solves for @cgriego's concern?

@MrJoy
MrJoy commented Jan 22, 2012

Working on this now. See pull request 561 as a precursor.

Also, regarding @criego's concern -- the whole point of this idea is that batch GC winds up being net faster in pretty much every case I can find. Batching is essentially trading off more memory usage for less CPU time usage.

@MrJoy
MrJoy commented Jan 22, 2012

Ok, patch provided. See pull request #561 for the full patch, plus fixes for a few warnings in your test suite.

@irongaze
irongaze commented Mar 7, 2012

+1

@bowsersenior

+1

@michihuber

In #653 it was decided that this should be a separate gem, which @MrJoy provides here: https://github.com/MrJoy/rspec-gc-control

This issue can be closed for now.

@alindeman alindeman closed this Feb 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment