Commit f09d546
Liu Zhongbo
builtin/fetch: iterate symrefs instead of all when checking dangling refs
refs_warn_dangling_symref() traverse all references to check if there are
any dangling symbolic references. The complexity is
O(number of deleted references * total number of references).
It will take a lot of time if there are tens of thousands of branches in
monorepo.
So I first identified all the symbolic references, and then only traverse
in these references. The complexity is
O (number of deleted references * number of symbolic references).
Due to the infrequent use of symbolic references, there will be significant
performance improvements here. In my case, the prune_refs() time has been
reduced from 20 seconds to 4 seconds.
Signed-off-by: Liu Zhongbo <[email protected]>1 parent ef8ce8f commit f09d546
3 files changed
+34
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1412 | 1412 | | |
1413 | 1413 | | |
1414 | 1414 | | |
| 1415 | + | |
| 1416 | + | |
1415 | 1417 | | |
1416 | 1418 | | |
1417 | 1419 | | |
1418 | 1420 | | |
1419 | 1421 | | |
1420 | 1422 | | |
1421 | | - | |
1422 | | - | |
| 1423 | + | |
| 1424 | + | |
1423 | 1425 | | |
| 1426 | + | |
1424 | 1427 | | |
1425 | 1428 | | |
1426 | 1429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
467 | | - | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
468 | 477 | | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
476 | 493 | | |
477 | 494 | | |
478 | 495 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
394 | 394 | | |
395 | 395 | | |
396 | 396 | | |
| 397 | + | |
| 398 | + | |
397 | 399 | | |
398 | | - | |
| 400 | + | |
399 | 401 | | |
400 | 402 | | |
401 | 403 | | |
| |||
0 commit comments