Commit 0822497
unpack-trees: improve performance of
To find the first non-unpacked cache entry, `next_cache_entry` iterates through
index, starting at `cache_bottom`, to find the first cache entry. The
performance of this in full indexes is helped by `cache_bottom` advancing with
each invocation of `mark_ce_used` (called by `unpack_index_entry`). However,
the presence of sparse directories can prevent the `cache_bottom` from
advancing in a sparse index case, effectively forcing `next_cache_entry` to
search from the beginning of the index each time it is called.
The need to preserve `cache_bottom` for the sparse index is documented in
17a1bb5, so to get the benefit it provides in "shortcutting"
already-searched entries a separate `hint` position is used. The hint position
is set inside of `next_cache_entry` to `last_searched_position + 1`, allowing
full _and_ sparse index iterations to skip already-searched entries. The
performance is significantly improved for the sparse index case based on the
`p2000` results for a `git reset` with a non-matching pathspec (heavily using
`next_cache_entry`):
Test ms/vfs-2.33.0 HEAD
------------------------------------------------------
(full-v3) 0.79(0.38+0.30) 0.91(0.43+0.34) +15.2%
(full-v4) 0.80(0.38+0.29) 0.85(0.40+0.35) +6.2%
(sparse-v3) 0.76(0.43+0.69) 0.44(0.08+0.67) -42.1%
(sparse-v4) 0.71(0.40+0.65) 0.41(0.09+0.65) -42.3%
Signed-off-by: Victoria Dye <vdye@github.com>next_cache_entry
1 parent 3499c91 commit 0822497
1 file changed
Lines changed: 17 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
668 | | - | |
| 668 | + | |
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
673 | 676 | | |
674 | 677 | | |
675 | | - | |
| 678 | + | |
| 679 | + | |
676 | 680 | | |
| 681 | + | |
677 | 682 | | |
678 | 683 | | |
| 684 | + | |
| 685 | + | |
679 | 686 | | |
680 | 687 | | |
681 | 688 | | |
| |||
1385 | 1392 | | |
1386 | 1393 | | |
1387 | 1394 | | |
| 1395 | + | |
1388 | 1396 | | |
1389 | 1397 | | |
1390 | 1398 | | |
1391 | 1399 | | |
1392 | 1400 | | |
1393 | | - | |
| 1401 | + | |
1394 | 1402 | | |
1395 | 1403 | | |
1396 | 1404 | | |
| |||
1719 | 1727 | | |
1720 | 1728 | | |
1721 | 1729 | | |
1722 | | - | |
| 1730 | + | |
1723 | 1731 | | |
1724 | 1732 | | |
1725 | 1733 | | |
| |||
1868 | 1876 | | |
1869 | 1877 | | |
1870 | 1878 | | |
| 1879 | + | |
| 1880 | + | |
1871 | 1881 | | |
1872 | 1882 | | |
1873 | 1883 | | |
1874 | 1884 | | |
1875 | 1885 | | |
1876 | 1886 | | |
1877 | | - | |
| 1887 | + | |
1878 | 1888 | | |
1879 | 1889 | | |
1880 | 1890 | | |
| |||
1895 | 1905 | | |
1896 | 1906 | | |
1897 | 1907 | | |
| 1908 | + | |
1898 | 1909 | | |
1899 | | - | |
| 1910 | + | |
1900 | 1911 | | |
1901 | 1912 | | |
1902 | 1913 | | |
| |||
0 commit comments