-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Request for Documentation on Optimal Thread and Job Allocation in Cargo Mutants #187
Comments
Hi, thanks for the suggestion and appreciation. Just checking, did you already read https://mutants.rs/parallelism.html?
Can you clarify what you mean by "allocating threads" here? There is really only one knob at the moment,
I'd like to give recommendations on that, but it seems to really depend on how resource-hungry your test suite is, so it's hard to generalize. In the extreme case perhaps even one copy of the test suite is as much as will fit on a small laptop or VM. At the moment the docs say
In fact I now think even I would welcome any suggestions. |
By threads, I wanted to refer to test-threads and I've seen it in the docs but also that these don't interact great together. Link to specific doc sentence |
I'm keenly interested in optimizing the execution of cargo mutants for this specific package: stackslib on the develop branch of the stacks-core repository. With the latest version of mutants, it's generating around 11.5k mutants. My current setup involves a 32vCPU and 64GB RAM configuration, where I've been running it with If possible, I'm open to upgrading the specs, but my main goal is to find the most efficient setup to significantly reduce the processing time from weeks or months to just hours. Any guidance on the ideal specifications and command adjustments for this task would be greatly appreciated. |
In addition to my previous query, I would also like to understand more about how cargo mutants utilizes CPU and memory resources, particularly in scenarios where there are spikes to 100% CPU and memory usage. I've experienced this firsthand both on the mentioned setup and locally on a macOS M1 with 32GB RAM. In my local case, I started the process, stepped away for a while, and returned to find the warning pop up about low memory, despite the system monitor showing only around 200MB of RAM usage, a great contrast to the 30GB it was consuming earlier, as it remained open from that spike moment. Could you provide insights into how cargo mutants manages memory and CPU during its execution? Specifically, does it cache builds/tests in memory for each job? How exactly does it allocate and utilize CPU resources for these processes? Understanding this could help in fine-tuning the system to handle the workload more efficiently, avoiding extreme resource consumption and system crashes. |
Starting with the concrete questions: I should probably make the manual more insistent about not setting it too high, even give a warning in the UI if Mentioning
I see that package is pretty large (220ksloc), so also to just concretely get started you might want to use If you are running this on a mac or Windows it's worth excluding your terminal or IDE from gatekeeper controls which can apparently have a pretty large effect: see #189. I ran the tests from that package and it looks like they take about 6 minutes total under nextest, with some individual tests taking >60s. I also saw some test failures with
which, maybe is a bug, or if these tests really need a lot of open files perhaps it's a great example of where you might need to pass There are some other flakes or failures too, which I guess is going to reduce my ability or enthusiasm to use this crate as a test case. If they are flaking in your environment then the mutants output probably won't be reliable either. I realize those slow tests might be important and hard to speed up but if you can, that would probably be the thing that helps most. Or, if these slow tests are more of a defense in depth and not relied on to catch every mutant or needing to be run on every commit, you might think about marking them As a ballpark in a tree that generates 11434 mutants and that has a test suite that takes 6 minutes I'd expect it would take at most 11434*6m = 48 days 😱 to test them all, ignoring the time for the incremental builds. Actually, some will be unviable, which will cut that time maybe in half, but it's still a lot, and I'd like to bring it down. In general I think Rust builds and tests are faster on Linux, and it's easier to use a ramdisk, so running in a beefy Linux VM would be one easy way to speed it up. I have an idea to allow sharding across multiple VMs, too, #192, so then you can get answers faster by spending money; this should parallelize almost perfectly to the point where 10k VMs might test everything in 10-20 minutes on this tree. More generally: The 99+% of the resource usage comes from it running So it's not really managing or allocating memory or CPU, any more than that shell script would be. Both these subprocesses are somewhat black boxes for cargo-mutants: it can't know a priori how much your tests will use when they run, or control how much RAM and CPU they use. Both the build tool and your own tests can be very hungry for CPU and RAM, and very spiky in how they use it. The spikes might account for your computer popping up a warning but then looking fine by the time you look at it. Both the build and test are typically trying to schedule many internal tasks in parallel, but they commonly go through phases where there is just one straggler using only one core. The point of
Not really, it runs It would be amazing if we could work out which tests possibly need to be run for any code change, perhaps by something like call graph analysis. It might have to look beyond direct reachability to catch changes due to side effects. But, if we could see that a particular test can never possibly execute a certain bit of code, then we could skip running that test. It seems possible in theory but I don't know yet how to get the information. The pragmatic answer is smaller crates which each have their own test coverage. On Linux it's good to put the tempdir in a ramdisk, which I guess you can see as a kind of caching. The idea we discussed elsewhere of running tests one at a time rather than through
|
For what it's worth I did get it running on that tree and it found some missed mutants. It is certainly projecting to take a long time. Your tree seems to need
|
i would say this issue can probably be closed #186 (comment) since documenting optimal threads/jobs is very dependent on the host OS. I'm not sure there could be an effective change to make it any more clear than the docs currently are. |
I think it can be clearer, actually: check out https://github.com/sourcefrog/cargo-mutants/pull/197/files?short_path=87dcc8f#diff-87dcc8f7e6732969e3a8b77e8e5ca6f99f6b88b834480dccc7bdb9c174c117dd But, after that, let's take the broader discussion to a Github Discussion since it's not exactly a single issue. |
I improved this in #197; let's continue in the Q&A forum. |
There appears to be a lack of documentation on the optimal usage of cargo mutants with respect to specifying the number of threads and jobs. Two critical aspects seem to be missing:
A guideline on the ratio between the number of threads and jobs. It's not clear when to allocate more jobs versus more threads, and in what scenarios to prioritize threads over jobs for certain types of builds or tests.
Recommendations based on CPU/RAM limits: Guidelines on determining the appropriate number of jobs and threads tailored to specific system specifications would be beneficial, ensuring that the tests run at full capacity without overloading the system.
Additionally, I'd like to say thank you for all the features in
cargo-mutants
and the ongoing development efforts.The text was updated successfully, but these errors were encountered: