• sprohaska's avatar
    convert: stream from fd to required clean filter to reduce used address space · 9035d75a
    sprohaska authored
    The data is streamed to the filter process anyway.  Better avoid mapping
    the file if possible.  This is especially useful if a clean filter
    reduces the size, for example if it computes a sha1 for binary data,
    like git media.  The file size that the previous implementation could
    handle was limited by the available address space; large files for
    example could not be handled with (32-bit) msysgit.  The new
    implementation can filter files of any size as long as the filter output
    is small enough.
    The new code path is only taken if the filter is required.  The filter
    consumes data directly from the fd.  If it fails, the original data is
    not immediately available.  The condition can easily be handled as
    a fatal error, which is expected for a required filter anyway.
    If the filter was not required, the condition would need to be handled
    in a different way, like seeking to 0 and reading the data.  But this
    would require more restructuring of the code and is probably not worth
    it.  The obvious approach of falling back to reading all data would not
    help achieving the main purpose of this patch, which is to handle large
    files with limited address space.  If reading all data is an option, we
    can simply take the old code path right away and mmap the entire file.
    The environment variable GIT_MMAP_LIMIT, which has been introduced in
    a previous commit is used to test that the expected code path is taken.
    A related test that exercises required filters is modified to verify
    that the data actually has been modified on its way from the file system
    to the object store.
    Signed-off-by: sprohaska's avatarSteffen Prohaska <[email protected]>
    Signed-off-by: default avatarJunio C Hamano <[email protected]>
t0021-conversion.sh 5.93 KB