Commit f99f965
committed
Auto merge of #9478 - ehuss:faster-git-status, r=alexcrichton
Improve performance of git status check in `cargo package`.
The check for a dirty repository during packaging/publishing is quite slow. It was calling `status_file` for every packaged file, which is very expensive. I have a directory that had about 10,000 untracked files. Previously, cargo would hang for over 2 minutes without any output. With this PR, it finishes in 0.3 seconds.
The solution here is to collect the status information once, and then compare the package list against it.
One subtle point is that it does not use `recurse_untracked_dirs`, and instead relies on a primitive `starts_with` comparison, which I believe should be equivalent.
This still includes an inefficient n^2 algorithm, but I am too lazy to make a better approach.
I'm moderately confident this is pretty much the same as before (at least, all the scenarios I could think of).File tree
3 files changed
+114
-48
lines changed- src/cargo/ops
- tests/testsuite
3 files changed
+114
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
417 | 412 | | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
| 413 | + | |
435 | 414 | | |
436 | 415 | | |
437 | 416 | | |
438 | 417 | | |
439 | 418 | | |
440 | 419 | | |
441 | | - | |
442 | | - | |
| 420 | + | |
| 421 | + | |
443 | 422 | | |
444 | 423 | | |
445 | 424 | | |
446 | 425 | | |
447 | 426 | | |
448 | 427 | | |
449 | 428 | | |
450 | | - | |
451 | | - | |
| 429 | + | |
| 430 | + | |
452 | 431 | | |
453 | 432 | | |
454 | 433 | | |
455 | 434 | | |
456 | | - | |
457 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
458 | 471 | | |
459 | | - | |
| 472 | + | |
460 | 473 | | |
461 | 474 | | |
462 | 475 | | |
463 | 476 | | |
464 | 477 | | |
465 | | - | |
466 | | - | |
| 478 | + | |
| 479 | + | |
467 | 480 | | |
468 | 481 | | |
469 | 482 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2760 | 2760 | | |
2761 | 2761 | | |
2762 | 2762 | | |
2763 | | - | |
| 2763 | + | |
2764 | 2764 | | |
2765 | 2765 | | |
2766 | 2766 | | |
| |||
2770 | 2770 | | |
2771 | 2771 | | |
2772 | 2772 | | |
2773 | | - | |
| 2773 | + | |
2774 | 2774 | | |
2775 | 2775 | | |
2776 | 2776 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
816 | 816 | | |
817 | 817 | | |
818 | 818 | | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
819 | 872 | | |
820 | 873 | | |
821 | 874 | | |
| |||
0 commit comments