Skip to content
This repository

add optional gc constraint to config #433

Closed
dchelimsky opened this Issue August 05, 2011 · 20 comments
David Chelimsky
Owner

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.

Justin Ko

Cool!

Mat Ellis

+1

Chris Griego

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.

David Chelimsky
Owner

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

Jon Frisby

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?

David Chelimsky
Owner

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

Chris Griego

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

Taylor luk

+1

Timo Borreck

+1

Lake Denman

+1

tmac

+1

David Chelimsky
Owner

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

Jon Frisby

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.

Jon Frisby

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

Rob Morris

+1

Michi Huber

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.

Andy Lindeman alindeman closed this February 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.