@matheusbsbs / matheus-bagliano / commits / e5808826c4
Fork 0

Remove unnecessary options from fast-import.

The --objects command line option is rather unnecessary. Internally we allocate objects in 5000 unit blocks, ensuring that any sort of malloc overhead is ammortized over the individual objects to almost nothing. Since most frontends don't know how many objects they will need for a given import run (and its hard for them to predict without just doing the run) we probably won't see anyone using --objects. Further since there's really no major benefit to using the option, most frontends won't even bother supplying it even if they could estimate the number of objects. So I'm removing it. The --max-objects-per-pack option was probably a mistake to even have added in the first place. The packfile format is limited to 4 GiB today; given that objects need at least 3 bytes of data (and probably need even more) there's no way we are going to exceed the limit of 1<<32-1 objects before we reach the file size limit. So I'm removing it (to slightly reduce the complexity of the code) before anyone gets any wise ideas and tries to use it. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Jan 18, 2007 at 12:00 UTC e5808826c4abe183b4db9bae8f13445624696f66
1 file changed +4 -12
fast-import.c
+4 -12
@@ -224,7 +224,6 @@ struct hash_list
224 /* Configured limits on output */
225 static unsigned long max_depth = 10;
226 static unsigned long max_packsize = (1LL << 32) - 1;
227 -static uintmax_t max_objects = -1;
227
228 /* Stats and misc. counters */
229 static uintmax_t alloc_count;
@@ -900,9 +899,7 @@ static int store_object(
899 deflateEnd(&s);
900
901 /* Determine if we should auto-checkpoint. */
903 - if ((object_count + 1) > max_objects
904 - || (object_count + 1) < object_count
905 - || (pack_size + 60 + s.total_out) > max_packsize
902 + if ((pack_size + 60 + s.total_out) > max_packsize
903 || (pack_size + 60 + s.total_out) < pack_size) {
904
905 /* This new object needs to *not* have the current pack_id. */
@@ -1872,12 +1869,11 @@ static void cmd_checkpoint(void)
1869 }
1870
1871 static const char fast_import_usage[] =
1875 -"git-fast-import [--objects=n] [--depth=n] [--active-branches=n] [--export-marks=marks.file] [--branch-log=log]";
1872 +"git-fast-import [--depth=n] [--active-branches=n] [--export-marks=marks.file] [--branch-log=log]";
1873
1874 int main(int argc, const char **argv)
1875 {
1876 int i;
1880 - uintmax_t est_obj_cnt = object_entry_alloc;
1877 uintmax_t total_count, duplicate_count;
1878
1879 setup_ident();
@@ -1888,10 +1884,6 @@ int main(int argc, const char **argv)
1884
1885 if (*a != '-' || !strcmp(a, "--"))
1886 break;
1891 - else if (!strncmp(a, "--objects=", 10))
1892 - est_obj_cnt = strtoumax(a + 10, NULL, 0);
1893 - else if (!strncmp(a, "--max-objects-per-pack=", 23))
1894 - max_objects = strtoumax(a + 23, NULL, 0);
1887 else if (!strncmp(a, "--max-pack-size=", 16))
1888 max_packsize = strtoumax(a + 16, NULL, 0) * 1024 * 1024;
1889 else if (!strncmp(a, "--depth=", 8))
@@ -1911,7 +1903,7 @@ int main(int argc, const char **argv)
1903 if (i != argc)
1904 usage(fast_import_usage);
1905
1914 - alloc_objects(est_obj_cnt);
1906 + alloc_objects(object_entry_alloc);
1907 strbuf_init(&command_buf);
1908
1909 atom_table = xcalloc(atom_table_sz, sizeof(struct atom_str*));
@@ -1955,7 +1947,7 @@ int main(int argc, const char **argv)
1947
1948 fprintf(stderr, "%s statistics:\n", argv[0]);
1949 fprintf(stderr, "---------------------------------------------------------------------\n");
1958 - fprintf(stderr, "Alloc'd objects: %10ju (%10ju overflow )\n", alloc_count, alloc_count - est_obj_cnt);
1950 + fprintf(stderr, "Alloc'd objects: %10ju\n", alloc_count);
1951 fprintf(stderr, "Total objects: %10ju (%10ju duplicates )\n", total_count, duplicate_count);
1952 fprintf(stderr, " blobs : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_BLOB], duplicate_count_by_type[OBJ_BLOB], delta_count_by_type[OBJ_BLOB]);
1953 fprintf(stderr, " trees : %10ju (%10ju duplicates %10ju deltas)\n", object_count_by_type[OBJ_TREE], duplicate_count_by_type[OBJ_TREE], delta_count_by_type[OBJ_TREE]);