Commit c793430
Limit file descriptors used by packs
Rather than using 'errno == EMFILE' after a failed open() call
to indicate the process is out of file descriptors and an LRU
pack window should be closed, place a hard upper limit on the
number of open packs based on the actual rlimit of the process.
By using a hard upper limit that is below the rlimit of the current
process it is not necessary to check for EMFILE on every single
fd-allocating system call. Instead reserving 25 file descriptors
makes it safe to assume the system call won't fail due to being over
the filedescriptor limit. Here 25 is chosen as a WAG, but considers
3 for stdin/stdout/stderr, and at least a few for other Git code
to operate on temporary files. An additional 20 is reserved as it
is not known what the C library needs to perform other services on
Git's behalf, such as nsswitch or name resolution.
This fixes a case where running `git gc --auto` in a repository
with more than 1024 packs (but an rlimit of 1024 open fds) fails
due to the temporary output file not being able to allocate a
file descriptor. The output file is opened by pack-objects after
object enumeration and delta compression are done, both of which
have already opened all of the packs and fully populated the file
descriptor table.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 62270f6 commit c793430
1 file changed
Lines changed: 30 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
| 421 | + | |
420 | 422 | | |
421 | 423 | | |
422 | 424 | | |
| |||
596 | 598 | | |
597 | 599 | | |
598 | 600 | | |
| 601 | + | |
599 | 602 | | |
600 | 603 | | |
601 | 604 | | |
| |||
680 | 683 | | |
681 | 684 | | |
682 | 685 | | |
683 | | - | |
| 686 | + | |
684 | 687 | | |
| 688 | + | |
| 689 | + | |
685 | 690 | | |
686 | 691 | | |
687 | 692 | | |
| |||
707 | 712 | | |
708 | 713 | | |
709 | 714 | | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
710 | 734 | | |
711 | 735 | | |
712 | 736 | | |
| 737 | + | |
713 | 738 | | |
714 | 739 | | |
715 | 740 | | |
| |||
761 | 786 | | |
762 | 787 | | |
763 | 788 | | |
| 789 | + | |
764 | 790 | | |
765 | 791 | | |
766 | 792 | | |
| |||
918 | 944 | | |
919 | 945 | | |
920 | 946 | | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
921 | 950 | | |
922 | 951 | | |
923 | 952 | | |
| |||
935 | 964 | | |
936 | 965 | | |
937 | 966 | | |
938 | | - | |
939 | | - | |
940 | 967 | | |
941 | 968 | | |
942 | 969 | | |
| |||
1092 | 1119 | | |
1093 | 1120 | | |
1094 | 1121 | | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | 1122 | | |
1104 | 1123 | | |
1105 | 1124 | | |
| |||
2359 | 2378 | | |
2360 | 2379 | | |
2361 | 2380 | | |
2362 | | - | |
2363 | | - | |
2364 | 2381 | | |
2365 | 2382 | | |
2366 | 2383 | | |
| |||
0 commit comments