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

Add support for enabling valgrind's fair-sched option? #51

Open
ivoanjo opened this issue Aug 19, 2024 · 1 comment
Open

Add support for enabling valgrind's fair-sched option? #51

ivoanjo opened this issue Aug 19, 2024 · 1 comment

Comments

@ivoanjo
Copy link

ivoanjo commented Aug 19, 2024

Hey 👋

Big thanks for ruby_memcheck. I've been setting it up to run in CI for the datadog gem (the profiling stuff especially has a lot of native code).

I am happy to report that (so far) I don't have any wins to report ;) ;) ;)

I would like to ask for a small feature: Adding support for controlling valgrind's --fair-sched option.

Right now I'm using the escape hatch RubyMemcheck.config(valgrind_options: ['--fair-sched=yes']) to set it.

Why this option? In several cases, our test suite assumes multi-threaded behavior (because, e.g. the profiler runs in parallel with the Ruby app), and in some cases we run stuff in forks; by default valgrind forces everything to run sequentially (there's a joke in here about adding an even more global GVL somewhere...). This makes some of our specs fail (usually with timeouts) or hang (because they busy-loop in a few cases) as they would on a single-core machine.

Using this setting makes these tests pass and saves us from manually needing to maintain a list of excluded tests just for ruby_memtest.

Thanks again! 🙇

@ivoanjo
Copy link
Author

ivoanjo commented Aug 20, 2024

Actually... when running with this setting it looks like sometimes valgrind doesn't write the full output? 🤔

Parsing of the result fails with FATAL: Premature end of data in tag valgrindoutput line 3 and indeed the output xml is missing closing that tag.

So, while it would be useful, I guess I won't use this setting for now. (Feel free to close the issue?)

ivoanjo added a commit to DataDog/dd-trace-rb that referenced this issue Aug 20, 2024
The [`ruby_memcheck`](https://github.com/Shopify/ruby_memcheck) gem
provides a Ruby-specific user-friendly wrapper around valgrind.

In some cases, some of our tests were hanging or timing out due
to how valgrind runs code in a sequential manner. I've added a
new tag to be able to skip such tests.

I also explored using valgrind's `fair-sched` option
(see Shopify/ruby_memcheck#51) but ran
into issues with its output being incomplete, so decided to go
the skip route instead.

You can run the new job with `bundle exec rake spec:profiling:memcheck`.
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

1 participant