taiki-e / cargo-llvm-cov

Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).
Apache License 2.0
900 stars 57 forks source link

Cleanup profraw files + `--no-clean` #292

Closed SamChou19815 closed 1 week ago

SamChou19815 commented 1 year ago

I really like the --no-clean flag since it makes incremental re-run of tests much faster. However, it eventually gets slower and slower since there are tons of profraw files generated.

In practice, I found that running rm -f target/llvm-cov-target/*.profraw before a llvm-cov run with --no-clean flag has the best of both world: the target/llvm-cov-target won't blow up in size, and we still get all the incremental runs' benefit.

Could this be added as a builtin flag so I don't have to write a custom script to do this?

taiki-e commented 1 year ago

Sounds reasonable to me.

TroyKomodo commented 1 year ago

Do incremental builds actually work?

$ cargo llvm-cov show-env
...
CARGO_INCREMENTAL="0"
...

Im curious why it has to be disabled?

taiki-e commented 1 year ago

@TroyKomodo --no-clean is unrelated to the incremental compilation of rustc itself, but improves the performance of successive builds, since the cleanup to prevent false positives in several situations that occur before the build and the rebuilds triggered by the cleanup are no longer performed.

CARGO_INCREMENTAL=0 was needed at some point in the past, but may no longer be needed with the cleanup in 0.1.5.

smoelius commented 1 month ago

Could this be added as a builtin flag so I don't have to write a custom script to do this?

I'm considering implementing this. What should an invocation look like?

taiki-e commented 3 weeks ago

What should an invocation look like?

I have no strong opinion about this, but I thought something like --no-clean=\

smoelius commented 3 weeks ago

I have no strong opinion about this, but I thought something like --no-clean=

An argument I would make against that is the following. To me, --no-clean=<option> suggests <option> specifies what should not be cleaned. If a user wants to keep everything except profraw files, <option> could be a long list. Also, it could hinder forward compatibility if new file types are stored in the llvm-cov-target directory.

An alternative I would propose is to add an option to cargo llvm-cov clean, perhaps --profraw-only.

Needless to say, I'll go with whatever you prefer, @taiki-e. :)

taiki-e commented 3 weeks ago

I agree with adding an option to clean subcommand is more reasonable.