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

Detect coverage earlier #63

Merged
merged 2 commits into from
Jun 19, 2017
Merged

Detect coverage earlier #63

merged 2 commits into from
Jun 19, 2017

Conversation

burke
Copy link
Member

@burke burke commented Jun 19, 2017

@grosser @jules2689

This should bail out of the iseq caching early enough. Testing whether the constant is defined is very fast. This should add less than 2ms to shopify boot.

Where this falls down is if coverage is eager-loaded by something, but not actually used.

The only ruby-land API available to us to test whether coverage is actually running is Coverage.peek_result, which appears to be quite expensive if coverage is currently running. I think that's unviable. I wonder if we can add a little function to the C extension to check this more economically.

Copy link
Contributor

@grosser grosser left a comment

Choose a reason for hiding this comment

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

a ruby issue could be nice to track it, but looks good

@burke
Copy link
Member Author

burke commented Jun 19, 2017

rb_get_coverages exists, though not in ruby.h. I extern'd it and this seems to work fine. I'll make a ruby issue too, it would be nice to have Coverage.running?

@grosser
Copy link
Contributor

grosser commented Jun 19, 2017

oh, sneaky :)

@burke
Copy link
Member Author

burke commented Jun 19, 2017

@jules2689
Copy link
Contributor

So this would add 1ms of time to check for coverage? 💩 I guess it's needed though

@burke
Copy link
Member Author

burke commented Jun 19, 2017

> Benchmark.realtime { $LOADED_FEATURES.size.times { defined?(Coverage) && Bootsnap::CompileCache::Native.coverage_running? } } - Benchmark.realtime { $LOADED_FEATURES.size.times { } }
=> 0.0005639999872073531

So yeah I'm not too worried about that.

@burke burke merged commit 5c71556 into master Jun 19, 2017
@burke burke deleted the coverage-detection branch June 19, 2017 19:59
@jules2689
Copy link
Contributor

Ah, ok. 👍.
I had just divided the 1.36s by 100 from here.

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

3 participants