taiki-e / cargo-hack

Cargo subcommand to provide various options useful for testing and continuous integration.
Apache License 2.0
628 stars 28 forks source link

`--feature-powerset` crashes `cargo-hack` and my terminal #227

Closed thomaseizinger closed 11 months ago

thomaseizinger commented 11 months ago

I'd like to adopt cargo-hack for testing a feature matrix of the libp2p facade crate, see https://github.com/libp2p/rust-libp2p.

Unfortunately, I can't seem to get it to work. I've tried to following locally:

cargo hack --package libp2p check --feature-powerset

This hangs for a few seconds and then crashes my terminal (Alacritty). The libp2p crate does have a few features (~40). Is that a problem?

If I resort to --each-feature, it starts compiling the crate. However, I'd like to use --at-least-one-of and that seems to be only compatible with --feature-powerset.

Let me know how I can provide more debug information or whether you can reproduce that locally.

taiki-e commented 11 months ago

Thanks for the report. The problem is OOM due to too many feature combinations.

In your case, this can be worked around by --depth option with a value smaller than 8 or 9. (At least on macOS 14)

Btw, with --depth 8, there are 51738694 feature combinations.

I think this is a reasonable limitation since it is not realistic to actually check such a large number of combinations (although should report error instead of crashing), but improving the implementation of the powerset calculation may reduce memory usage.

thomaseizinger commented 11 months ago

Ah I see :sweat_smile:

I guess what I want is --depth 2 and --at-least-one-of!