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

No-op Configuration #591

Open
XAMPPRocky opened this issue Aug 24, 2018 · 10 comments
Open

No-op Configuration #591

XAMPPRocky opened this issue Aug 24, 2018 · 10 comments

Comments

@XAMPPRocky
Copy link

When using flamegraph profiling rayon pollutes the call stack making it very hard to find my code in the graph, and I have to manually replace all instances of par_. It'd be nice if I could instead enable a feature flag in rayon so that I don't have to change every code instance and just have to change Cargo.toml that simply made all parallel iterator calls sequential. I've included two graphs below with and without rayon calls to show the disparity between the two.

With rayon

with-rayon

Without rayon

no-rayon

@nikomatsakis
Copy link
Member

Making this a feature makes me a bit nervous — if you accidentally committed it, or published with it, it would propagate to all your dependencies etc...

We could make a cfg setting that you have to set up with RUSTFLAGS easily enough though.

@cuviper
Copy link
Member

cuviper commented Aug 29, 2018

Is it good enough for you to just use RUST_NUM_THREADS=1 in your environment? You'll still see some rayon in your callstack this way, but it should be greatly reduced.

AIUI flamegraph does a lot of post-processing in scripts. I wonder if you could just filter unwanted rayon symbols from your stacks that way? Then you'll still be representing the parallel workload otherwise, which could be helpful.

@XAMPPRocky
Copy link
Author

@nikomatsakis That concern is completely valid. I was just using feature as an example. Any solution that is a single switch to flip is equally satisfactory.

@cuviper I've attached below what it looks like with RUST_NUM_THREADS=1 while it is shallower, it is still far from readable in my opinion.

no-rayon

@mashedcode
Copy link

We could make a cfg setting that you have to set up with RUSTFLAGS easily enough though.

That sounds like a great solution!

@XAMPPRocky XAMPPRocky changed the title Feature Request: No-op feature flag No-op Configuration Jul 10, 2020
@AnEnigmaticBug
Copy link

We could make a cfg setting that you have to set up with RUSTFLAGS easily enough though.

Hi. Is there any update on this? I see that the issue has been open for 4 years now. Just wanted to check if it will be picked up some time later this year. I also have the same use case (cleaning up perf output) and would love to have this!

If no one is taking a shot, I can try making a pull request (disclaimer: I haven't looked at rayon internals till now). Any pointers would be really helpful!

@cuviper
Copy link
Member

cuviper commented Oct 25, 2022

Also see the discussion in #861, but I'm not aware of anyone actually working on it yet.

@RReverser
Copy link
Contributor

I believe this was closed by #1019 / #861?

@cuviper
Copy link
Member

cuviper commented Jan 23, 2024

Not entirely -- I think OP wanted this on platforms that do support threads well, but all the work-stealing makes it hard to decipher what's going on in tools that look at backtraces, like flamegraph.

I have had luck using cargo flamegraph --skip-after=SYMBOL when there a decent entry point into the parallel work to filter on, or even just using the rayon_core::join::... functions in some cases. Then it can run fully parallel and still get a decently understandable flamegraph image.

@RReverser
Copy link
Contributor

Not entirely -- I think OP wanted this on platforms that do support threads well

Ah so the functionality is there, but the --cfg opt-in is still missing.

@cuviper
Copy link
Member

cuviper commented Jan 23, 2024

You could also set threads=1 and use_current_thread (#1063).

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

6 participants