|
24 | 24 | #include "streaming.h"
|
25 | 25 | #include "thread-utils.h"
|
26 | 26 | #include "pack-bitmap.h"
|
| 27 | +#include "delta-islands.h" |
27 | 28 | #include "reachable.h"
|
28 | 29 | #include "sha1-array.h"
|
29 | 30 | #include "argv-array.h"
|
@@ -59,6 +60,7 @@ static struct packing_data to_pack;
|
59 | 60 |
|
60 | 61 | static struct pack_idx_entry **written_list;
|
61 | 62 | static uint32_t nr_result, nr_written, nr_seen;
|
| 63 | +static uint32_t write_layer; |
62 | 64 |
|
63 | 65 | static int non_empty;
|
64 | 66 | static int reuse_delta = 1, reuse_object = 1;
|
@@ -93,6 +95,8 @@ static uint16_t write_bitmap_options;
|
93 | 95 |
|
94 | 96 | static int exclude_promisor_objects;
|
95 | 97 |
|
| 98 | +static int use_delta_islands; |
| 99 | + |
96 | 100 | static unsigned long delta_cache_size = 0;
|
97 | 101 | static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;
|
98 | 102 | static unsigned long cache_max_small_delta_size = 1000;
|
@@ -607,7 +611,7 @@ static inline void add_to_write_order(struct object_entry **wo,
|
607 | 611 | unsigned int *endp,
|
608 | 612 | struct object_entry *e)
|
609 | 613 | {
|
610 |
| - if (e->filled) |
| 614 | + if (e->filled || e->layer != write_layer) |
611 | 615 | return;
|
612 | 616 | wo[(*endp)++] = e;
|
613 | 617 | e->filled = 1;
|
@@ -710,13 +714,14 @@ static void compute_layer_order(struct object_entry **wo, unsigned int *wo_end)
|
710 | 714 | * Finally all the rest in really tight order
|
711 | 715 | */
|
712 | 716 | for (i = last_untagged; i < to_pack.nr_objects; i++) {
|
713 |
| - if (!objects[i].filled) |
| 717 | + if (!objects[i].filled && objects[i].layer == write_layer) |
714 | 718 | add_family_to_write_order(wo, wo_end, &objects[i]);
|
715 | 719 | }
|
716 | 720 | }
|
717 | 721 |
|
718 | 722 | static struct object_entry **compute_write_order(void)
|
719 | 723 | {
|
| 724 | + uint32_t max_layers = 1; |
720 | 725 | unsigned int i, wo_end;
|
721 | 726 |
|
722 | 727 | struct object_entry **wo;
|
@@ -748,14 +753,14 @@ static struct object_entry **compute_write_order(void)
|
748 | 753 | */
|
749 | 754 | for_each_tag_ref(mark_tagged, NULL);
|
750 | 755 |
|
751 |
| - /* |
752 |
| - * Give the objects in the original recency order until |
753 |
| - * we see a tagged tip. |
754 |
| - */ |
| 756 | + if (use_delta_islands) |
| 757 | + max_layers = compute_pack_layers(&to_pack); |
| 758 | + |
755 | 759 | ALLOC_ARRAY(wo, to_pack.nr_objects);
|
756 | 760 | wo_end = 0;
|
757 | 761 |
|
758 |
| - compute_layer_order(wo, &wo_end); |
| 762 | + for (; write_layer < max_layers; ++write_layer) |
| 763 | + compute_layer_order(wo, &wo_end); |
759 | 764 |
|
760 | 765 | if (wo_end != to_pack.nr_objects)
|
761 | 766 | die("ordered %u objects, expected %"PRIu32, wo_end, to_pack.nr_objects);
|
@@ -1514,7 +1519,8 @@ static void check_object(struct object_entry *entry)
|
1514 | 1519 | break;
|
1515 | 1520 | }
|
1516 | 1521 |
|
1517 |
| - if (base_ref && (base_entry = packlist_find(&to_pack, base_ref, NULL))) { |
| 1522 | + if (base_ref && (base_entry = packlist_find(&to_pack, base_ref, NULL)) && |
| 1523 | + in_same_island(&entry->idx.oid, &base_entry->idx.oid)) { |
1518 | 1524 | /*
|
1519 | 1525 | * If base_ref was set above that means we wish to
|
1520 | 1526 | * reuse delta data, and we even found that base
|
@@ -1830,6 +1836,11 @@ static int type_size_sort(const void *_a, const void *_b)
|
1830 | 1836 | return -1;
|
1831 | 1837 | if (a->preferred_base < b->preferred_base)
|
1832 | 1838 | return 1;
|
| 1839 | + if (use_delta_islands) { |
| 1840 | + int island_cmp = island_delta_cmp(&a->idx.oid, &b->idx.oid); |
| 1841 | + if (island_cmp) |
| 1842 | + return island_cmp; |
| 1843 | + } |
1833 | 1844 | if (a_size > b_size)
|
1834 | 1845 | return -1;
|
1835 | 1846 | if (a_size < b_size)
|
@@ -1978,6 +1989,9 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
|
1978 | 1989 | if (trg_size < src_size / 32)
|
1979 | 1990 | return 0;
|
1980 | 1991 |
|
| 1992 | + if (!in_same_island(&trg->entry->idx.oid, &src->entry->idx.oid)) |
| 1993 | + return 0; |
| 1994 | + |
1981 | 1995 | /* Load data if not already done */
|
1982 | 1996 | if (!trg->data) {
|
1983 | 1997 | read_lock();
|
@@ -2516,6 +2530,9 @@ static void prepare_pack(int window, int depth)
|
2516 | 2530 | uint32_t i, nr_deltas;
|
2517 | 2531 | unsigned n;
|
2518 | 2532 |
|
| 2533 | + if (use_delta_islands) |
| 2534 | + resolve_tree_islands(progress, &to_pack); |
| 2535 | + |
2519 | 2536 | get_object_details();
|
2520 | 2537 |
|
2521 | 2538 | /*
|
@@ -2679,13 +2696,29 @@ static void show_commit(struct commit *commit, void *data)
|
2679 | 2696 |
|
2680 | 2697 | if (write_bitmap_index)
|
2681 | 2698 | index_commit_for_bitmap(commit);
|
| 2699 | + |
| 2700 | + if (use_delta_islands) |
| 2701 | + propagate_island_marks(commit); |
2682 | 2702 | }
|
2683 | 2703 |
|
2684 | 2704 | static void show_object(struct object *obj, const char *name, void *data)
|
2685 | 2705 | {
|
2686 | 2706 | add_preferred_base_object(name);
|
2687 | 2707 | add_object_entry(&obj->oid, obj->type, name, 0);
|
2688 | 2708 | obj->flags |= OBJECT_ADDED;
|
| 2709 | + |
| 2710 | + if (use_delta_islands) { |
| 2711 | + const char *p; |
| 2712 | + unsigned depth = 0; |
| 2713 | + struct object_entry *ent; |
| 2714 | + |
| 2715 | + for (p = strchr(name, '/'); p; p = strchr(p + 1, '/')) |
| 2716 | + depth++; |
| 2717 | + |
| 2718 | + ent = packlist_find(&to_pack, obj->oid.hash, NULL); |
| 2719 | + if (ent && depth > ent->tree_depth) |
| 2720 | + ent->tree_depth = depth; |
| 2721 | + } |
2689 | 2722 | }
|
2690 | 2723 |
|
2691 | 2724 | static void show_object__ma_allow_any(struct object *obj, const char *name, void *data)
|
@@ -3013,6 +3046,9 @@ static void get_object_list(int ac, const char **av)
|
3013 | 3046 | if (use_bitmap_index && !get_object_list_from_bitmap(&revs))
|
3014 | 3047 | return;
|
3015 | 3048 |
|
| 3049 | + if (use_delta_islands) |
| 3050 | + load_delta_islands(); |
| 3051 | + |
3016 | 3052 | if (prepare_revision_walk(&revs))
|
3017 | 3053 | die("revision walk setup failed");
|
3018 | 3054 | mark_edges_uninteresting(&revs, show_edge);
|
@@ -3192,6 +3228,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
|
3192 | 3228 | option_parse_missing_action },
|
3193 | 3229 | OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects,
|
3194 | 3230 | N_("do not pack objects in promisor packfiles")),
|
| 3231 | + OPT_BOOL(0, "delta-islands", &use_delta_islands, |
| 3232 | + N_("respect islands during delta compression")), |
3195 | 3233 | OPT_END(),
|
3196 | 3234 | };
|
3197 | 3235 |
|
@@ -3318,6 +3356,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
|
3318 | 3356 | if (pack_to_stdout || !rev_list_all)
|
3319 | 3357 | write_bitmap_index = 0;
|
3320 | 3358 |
|
| 3359 | + if (use_delta_islands) |
| 3360 | + argv_array_push(&rp, "--topo-order"); |
| 3361 | + |
3321 | 3362 | if (progress && all_progress_implied)
|
3322 | 3363 | progress = 2;
|
3323 | 3364 |
|
|
0 commit comments