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

Use of ractors makes coverage non-deterministic #1058

Closed
fdr opened this issue May 17, 2023 · 3 comments
Closed

Use of ractors makes coverage non-deterministic #1058

fdr opened this issue May 17, 2023 · 3 comments

Comments

@fdr
Copy link

fdr commented May 17, 2023

I didn't see any previous mention of ractors in the issue tracker, so I suspect I may be the first reporter to have tried to use them. In my case, I had a short-lived ractor that would exit at some indeterminate time in the course of my test suite.

What I've found is that it makes the coverage numbers fluctuate chaotically. I suspect something like an inherited at_exit hook may be to blame.

If a mechanical theory for this does not jump out at you, I will try to write a minimizing test demonstrator. But I figured you may expect things to misbehave this way, and nobody has asked about it on the issue tracker yet.

fdr added a commit to ubicloud/ubicloud that referenced this issue May 18, 2023
Alas, Ractors cause some problems with non-deterministic coverage
results, that do not occur with Threads.  It looks suspiciously like
the Ractors are flushing coverage state to me.

I wrote a somewhat superficial bug report at
simplecov-ruby/simplecov#1058 about this.

In the past, I have managed this problem with Threads, and they've
been fine, even if they widen the potential for a theoretical problem
of a thread not getting scheduled because of a bug in other code in
releasing the GVL.
fdr added a commit to ubicloud/ubicloud that referenced this issue May 18, 2023
Alas, Ractors cause some problems with non-deterministic coverage
results, that do not occur with Threads.  It looks suspiciously like
the Ractors are flushing coverage state to me.

I wrote a somewhat superficial bug report at
simplecov-ruby/simplecov#1058 about this.

In the past, I have managed this problem with Threads, and they've
been fine, even if they widen the potential for a theoretical problem
of a thread not getting scheduled because of a bug in other code in
releasing the GVL.
@colszowka
Copy link
Collaborator

@fdr I don't think this has been brought up before, and granted that ractors aren't yet very common in use in ruby as far as I know I think it's possible it wasn't yet tried out. It would be nice to know whether this is related to simplecov or the ruby stdlib coverage module itself in the first place, because in the latter case this issue should be reported in the ruby issue tracker first.

If you try to make an isolated example, could you please first try to do it with the coverage module first?

fdr added a commit to ubicloud/ubicloud that referenced this issue May 18, 2023
Alas, Ractors cause some problems with non-deterministic coverage
results, that do not occur with Threads.  It looks suspiciously like
the Ractors are flushing coverage state to me.

I wrote a somewhat superficial bug report at
simplecov-ruby/simplecov#1058 about this.

In the past, I have managed this problem with Threads, and they've
been fine, even if they widen the potential for a theoretical problem
of a thread not getting scheduled because of a bug in other code in
releasing the GVL.
@fdr
Copy link
Author

fdr commented May 18, 2023

Interesting, I didn't consider that. I'll research the matter. Maybe I'll close this until I have the time, it may still be useful to someone running a search.

@fdr fdr closed this as completed May 18, 2023
@jaynetics
Copy link

I just spent quite a bit of time finding this out, so maybe this issue should stay open :)

It seems to be a problem with Ruby's own Coverage module, so I've opened an issue in the Ruby bug tracker.

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

3 participants