git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 4/4] diff: mark any file larger than core.bigfilethreshold binary

From
Duy Nguyen <pclouds@gmail.com>
Date
Jun 29, 2014, 01:11 UTC
Message-ID
<CACsJy8BobwPCnyBgYJw6yVZF_05aKeaBGRe=C4GxvUL4V58y_Q@mail.gmail.com>
In-Reply-To
<53ADBE51.9050005@virtuell-zuhause.de>

On Sat, Jun 28, 2014 at 1:56 AM, Thomas Braun <thomas.braun@virtuell-zuhause.de> wrote:

Show 18 quoted lines
>> The name is misleading and forced me to read it twice before I
>> realized that this is "populating the is-binary bit".  It might make
>> it a bit better if you renamed it to DIFF_POPULATE_IS_BINARY_BIT or
>> perhaps DIFF_POPULATE_CHECK_BINARY or something.  For consistency,
>> the other bit may want to be also renamed from SIZE_ONLY to either
>>
>>  (1) CHECK_SIZE_ONLY
>>
>>  (2) One bit for CHECK_SIZE, another for NO_CONTENTS, and optionally
>>      make SIZE_ONLY the union of two
>>
>> I do not have strong preference either way; the latter may be more
>> logical in that "not loading contents" and "check size" are sort of
>> orthogonal in that you can later choose to check, without loading
>> contents, only the binary-ness without checking size, but no calles
>> that passes a non-zero flag to the populate-filespec function will
>> want to slurp in the contents in practice, so in that sense we could
>> declare that the NO_CONENTS bit is implied.
Will do (and probably go with (1) as I still prefer zero as "good defaults")
>> But more importantly, would this patch actually help?

Well yes as demonstrated by the new test ;-) Unfortunately the scope of help is limited to --stat.. I should have done more thorough testing.

Show 52 quoted lines
>> For one
>> thing, this wouldn't (and shouldn't) help if the user wants --binary
>> diff out of us anyway, I suspect, but I wonder what the following
>> codepath in the builtin_diff() function would do:
>>
>>               ...
>>       } else if (!DIFF_OPT_TST(o, TEXT) &&
>>           ( (!textconv_one && diff_filespec_is_binary(one)) ||
>>             (!textconv_two && diff_filespec_is_binary(two)) )) {
>>               if (fill_mmfile(&mf1, one) < 0 || fill_mmfile(&mf2, two) < 0)
>>                       die("unable to read files to diff");
>>               /* Quite common confusing case */
>>               if (mf1.size == mf2.size &&
>>                   !memcmp(mf1.ptr, mf2.ptr, mf1.size)) {
>>                       if (must_show_header)
>>                               fprintf(o->file, "%s", header.buf);
>>                       goto free_ab_and_return;
>>               }
>>               fprintf(o->file, "%s", header.buf);
>>               strbuf_reset(&header);
>>               if (DIFF_OPT_TST(o, BINARY))
>>                       emit_binary_diff(o->file, &mf1, &mf2, line_prefix);
>>               else
>>                       fprintf(o->file, "%sBinary files %s and %s differ\n",
>>                               line_prefix, lbl[0], lbl[1]);
>>               o->found_changes = 1;
>>       } else {
>>               ...
>>
>> If we weren't told with --text/-a to force textual output, and
>> at least one of the sides is marked as binary (and this patch marks
>> a large blob as binary unless attributes says otherwise), we still
>> call fill_mmfile() on them to slurp the contents to be compared, no?
>>
>> And before you get to the DIFF_OPT_TST(o, BINARY), you memcmp(3) to
>> check if the sides are identical, so...
>
> Good point. So how about an additional change roughly sketched as
>
> @@ -2223,6 +2223,14 @@ struct userdiff_driver *get_textconv(struct
> diff_filespec *one)
>         return userdiff_get_textconv(one->driver);
>  }
>
> +/* read the files in small chunks into memory and compare them */
> +static int filecmp_chunked(struct diff_filespec *one,
> +       struct diff_filespec *two)
> +{
> +       // TODO add implementation
> +       return 0;
> +}
> +

We have object streaming interface to do similar like this. In fact index-pack already does large file memcmp() for hash collision test. I think I can move some code around and support large file in this code path..

-- 
Duy
Previous: Thomas BraunNext: Nguyễn Thái Ngọc Duy
Message 27 of 49 in “Git chokes on large file”
  1. Dale R. WorleyMay 27, 2014
  2. Duy NguyenMay 28, 2014
  3. Junio C HamanoMay 28, 2014
  4. Dale R. WorleyMay 28, 2014
  5. Dale R. WorleyMay 28, 2014
  6. David LangMay 28, 2014
  7. Dale R. WorleyMay 28, 2014
  8. David LangMay 28, 2014
  9. Dale R. WorleyMay 29, 2014
  10. Junio C HamanoMay 28, 2014
  11. David LangMay 28, 2014
  12. 1/4 wrapper.c: introduce gentle xmallocz that does not die()Nguyễn Thái Ngọc Duy, May 29, 2014
  13. 2/4 fsck: do not die when not enough memory to examine a pack entryNguyễn Thái Ngọc Duy, May 29, 2014
  14. 3/4 diff.c: allow to pass more flags to diff_populate_filespecNguyễn Thái Ngọc Duy, May 29, 2014
  15. 4/4 diff: mark any file larger than core.bigfilethreshold binaryNguyễn Thái Ngọc Duy, May 29, 2014
  16. Thomas BraunJun 19, 2014
  17. Duy NguyenJun 23, 2014
  18. Thomas BraunJun 23, 2014
  19. 1/4 wrapper.c: introduce gentle xmallocz that does not die()Nguyễn Thái Ngọc Duy, Jun 24, 2014
  20. 2/4 fsck: do not die when not enough memory to examine a pack entryNguyễn Thái Ngọc Duy, Jun 24, 2014
  21. Junio C HamanoJun 26, 2014
  22. Duy NguyenJun 29, 2014
  23. 3/4 diff.c: allow to pass more flags to diff_populate_filespecNguyễn Thái Ngọc Duy, Jun 24, 2014
  24. 4/4 diff: mark any file larger than core.bigfilethreshold binaryNguyễn Thái Ngọc Duy, Jun 24, 2014
  25. Junio C HamanoJun 26, 2014
  26. Thomas BraunJun 27, 2014
  27. Duy NguyenJun 29, 2014
  28. 0/6 Large file improvementsNguyễn Thái Ngọc Duy, Aug 13, 2014
  29. 1/6 wrapper.c: introduce gentle xmalloc(z) that does not die()Nguyễn Thái Ngọc Duy, Aug 13, 2014
  30. Junio C HamanoAug 14, 2014
  31. 2/6 sha1_file.c: do not die failing to malloc in unpack_compressed_entryNguyễn Thái Ngọc Duy, Aug 13, 2014
  32. Junio C HamanoAug 13, 2014
  33. 3/6 unpack-objects: continue when fail to malloc due to large objectsNguyễn Thái Ngọc Duy, Aug 13, 2014
  34. Junio C HamanoAug 14, 2014
  35. Duy NguyenAug 15, 2014
  36. 4/6 diff.c: allow to pass more flags to diff_populate_filespecNguyễn Thái Ngọc Duy, Aug 13, 2014
  37. 5/6 diff --stat: mark any file larger than core.bigfilethreshold binaryNguyễn Thái Ngọc Duy, Aug 13, 2014
  38. Eric SunshineAug 13, 2014
  39. 6/6 diff: shortcut for diff'ing two binary SHA-1 objectsNguyễn Thái Ngọc Duy, Aug 13, 2014
  40. Junio C HamanoAug 14, 2014
  41. Duy NguyenAug 15, 2014
  42. Junio C HamanoAug 14, 2014
  43. 0/5 Large file improvementsNguyễn Thái Ngọc Duy, Aug 16, 2014
  44. 1/5 wrapper.c: introduce gentle xmallocz that does not die()Nguyễn Thái Ngọc Duy, Aug 16, 2014
  45. 2/5 sha1_file.c: do not die failing to malloc in unpack_compressed_entryNguyễn Thái Ngọc Duy, Aug 16, 2014
  46. 3/5 diff.c: allow to pass more flags to diff_populate_filespecNguyễn Thái Ngọc Duy, Aug 16, 2014
  47. 4/5 diff --stat: mark any file larger than core.bigfilethreshold binaryNguyễn Thái Ngọc Duy, Aug 16, 2014
  48. 5/5 diff: shortcut for diff'ing two binary SHA-1 objectsNguyễn Thái Ngọc Duy, Aug 16, 2014
  49. Thomas BraunMay 28, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.