Commit 583bc41
fetch: make
When fetching with the `--prune` flag we will delete any local
references matching the fetch refspec which have disappeared on the
remote. This step is not currently covered by the `--atomic` flag: we
delete branches even though updating of local references has failed,
which means that the fetch is not an all-or-nothing operation.
Fix this bug by passing in the global transaction into `prune_refs()`:
if one is given, then we'll only queue up deletions and not commit them
right away.
This change also improves performance when pruning many branches in a
repository with a big packed-refs file: every references is pruned in
its own transaction, which means that we potentially have to rewrite
the packed-refs files for every single reference we're about to prune.
The following benchmark demonstrates this: it performs a pruning fetch
from a repository with a single reference into a repository with 100k
references, which causes us to prune all but one reference. This is of
course a very artificial setup, but serves to demonstrate the impact of
only having to write the packed-refs file once:
Benchmark 1: git fetch --prune --atomic +refs/*:refs/* (HEAD~)
Time (mean ± σ): 2.366 s ± 0.021 s [User: 0.858 s, System: 1.508 s]
Range (min … max): 2.328 s … 2.407 s 10 runs
Benchmark 2: git fetch --prune --atomic +refs/*:refs/* (HEAD)
Time (mean ± σ): 1.369 s ± 0.017 s [User: 0.715 s, System: 0.641 s]
Range (min … max): 1.346 s … 1.400 s 10 runs
Summary
'git fetch --prune --atomic +refs/*:refs/* (HEAD)' ran
1.73 ± 0.03 times faster than 'git fetch --prune --atomic +refs/*:refs/* (HEAD~)'
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>--atomic flag cover pruning of refs1 parent b3a8046 commit 583bc41
2 files changed
+24
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1338 | 1338 | | |
1339 | 1339 | | |
1340 | 1340 | | |
1341 | | - | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
1342 | 1344 | | |
1343 | 1345 | | |
1344 | 1346 | | |
1345 | 1347 | | |
| 1348 | + | |
1346 | 1349 | | |
1347 | 1350 | | |
1348 | 1351 | | |
| |||
1363 | 1366 | | |
1364 | 1367 | | |
1365 | 1368 | | |
1366 | | - | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1367 | 1378 | | |
1368 | | - | |
1369 | | - | |
| 1379 | + | |
| 1380 | + | |
1370 | 1381 | | |
1371 | | - | |
1372 | | - | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
1373 | 1385 | | |
1374 | 1386 | | |
1375 | 1387 | | |
| |||
1388 | 1400 | | |
1389 | 1401 | | |
1390 | 1402 | | |
| 1403 | + | |
| 1404 | + | |
1391 | 1405 | | |
1392 | 1406 | | |
1393 | 1407 | | |
| |||
1629 | 1643 | | |
1630 | 1644 | | |
1631 | 1645 | | |
1632 | | - | |
| 1646 | + | |
1633 | 1647 | | |
1634 | 1648 | | |
1635 | | - | |
| 1649 | + | |
1636 | 1650 | | |
1637 | 1651 | | |
1638 | 1652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
358 | | - | |
359 | | - | |
| 357 | + | |
360 | 358 | | |
361 | 359 | | |
362 | 360 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | 361 | | |
367 | 362 | | |
| 363 | + | |
368 | 364 | | |
369 | 365 | | |
370 | 366 | | |
| |||
0 commit comments