这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@9999years
Copy link
Contributor

Closes #124.

This is the naive approach, which does not attempt to read files or compute diagnostics in parallel (unless there's some salsa magic I don't understand happening under the hood).

I was expecting this to be pretty slow, but on a codebase with 234 Nix files comprising 14,000 LOC, nil diagnostics **/*.nix completes in 33ms. (Compare this to parallel --max-args 1 nil diagnostics ::: **/*.nix, which takes a full 4 seconds.)

If we try nil diagnostics **/*.nix in nixpkgs, we get:

exec: Failed to execute process 'nil': the total size of the argument list and exported variables (1.5MB) exceeds the OS limit of 1MB.

Which was to be expected. Using find to execute nil diagnostics with as many arguments as possible (find . -path '*.nix' -exec nil diagnostics {} +) completes in just 6.5 seconds! (That's to analyze 32,800 files containing 3 million LOC.)

The comparable command for one-invocation-per-file (find . -path '*.nix' | parallel --pipe --cat -L 1 --max-args 1 nil diagnostics {}) takes... well, it's still running.

@oxalica oxalica added A-diagnostics Area: diagnostics / error reporting A-CLI Area: command line interface C-feature Catagory: feature labels Aug 7, 2024
@lucasew
Copy link

lucasew commented Jan 7, 2025

This is what I am using in nixpkgs:

for item in **/*.nix; do nil diagnostics $item >/dev/null || echo $item; done | tee nil-failures.log

Suboptimal? Yes. But it solves the problem.

@9999years
Copy link
Contributor Author

Suboptimal? Yes. But it solves the problem.

Sure. I don't think the fact that a workaround exists is a good reason to avoid making any improvements here, especially given how common a workflow this is and how many comparable tools support recursive file discovery.

@lf-
Copy link

lf- commented May 5, 2025

Assuming that we fixed the merge conflicts, is this PR acceptable in principle @oxalica?

@oxalica oxalica closed this in 9e32aad Jun 13, 2025
@oxalica
Copy link
Owner

oxalica commented Jun 13, 2025

Manually merged with a few nit tweaks. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: command line interface A-diagnostics Area: diagnostics / error reporting C-feature Catagory: feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Diagnostics for multiple files

4 participants