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 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 left a comment

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

@burke

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

grosser commented Jun 19, 2017

oh, sneaky :)

@burke

This comment has been minimized.

Copy link
Member Author

burke commented Jun 19, 2017

@burke burke force-pushed the coverage-detection branch from 8a15bc4 to 6924fec Jun 19, 2017
@burke burke force-pushed the coverage-detection branch from 6924fec to 2029239 Jun 19, 2017
@jules2689

This comment has been minimized.

Copy link
Contributor

jules2689 commented Jun 19, 2017

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

@burke

This comment has been minimized.

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
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
@burke burke deleted the coverage-detection branch Jun 19, 2017
@jules2689

This comment has been minimized.

Copy link
Contributor

jules2689 commented Jun 19, 2017

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
Projects
None yet
3 participants
You can’t perform that action at this time.