Message ID | 20190307195657.GA29776@sigill.intra.peff.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | convert: avoid malloc of original file size | expand |
Jeff King <peff@peff.net> writes: > As discussed there, I do think this only solves half the problem, as the > smudge filter has the same issue in reverse. That's more complicated to > fix, and AFAIK nobody is working on it. But I don't think there's any > reason not to pick up this part in the meantime. Yeah, I agree that the reverse direction shares the same issue. I am not sure 0 is a good initial value in this direction, either; I'd rather clip to min(len, core.bigfilethreshold) or something like that, to avoid regressing the more normal use cases. But let's queue this and see what happens. Thanks. > > convert.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/convert.c b/convert.c > index 5d0307fc10..94ff837649 100644 > --- a/convert.c > +++ b/convert.c > @@ -731,7 +731,7 @@ static int apply_single_file_filter(const char *path, const char *src, size_t le > if (start_async(&async)) > return 0; /* error was already reported */ > > - if (strbuf_read(&nbuf, async.out, len) < 0) { > + if (strbuf_read(&nbuf, async.out, 0) < 0) { > err = error(_("read from external filter '%s' failed"), cmd); > } > if (close(async.out)) {
On Fri, Mar 08, 2019 at 10:26:24AM +0900, Junio C Hamano wrote: > Jeff King <peff@peff.net> writes: > > > As discussed there, I do think this only solves half the problem, as the > > smudge filter has the same issue in reverse. That's more complicated to > > fix, and AFAIK nobody is working on it. But I don't think there's any > > reason not to pick up this part in the meantime. > > Yeah, I agree that the reverse direction shares the same issue. > > I am not sure 0 is a good initial value in this direction, either; > I'd rather clip to min(len, core.bigfilethreshold) or something like > that, to avoid regressing the more normal use cases. That was my initial thought, too, but Joey's benchmarks show that it doesn't seem to make a big difference either way. In his numbers it did get measurable for a 1GB file, but we'd still not use "hint == len" in that case (we'd probably do one or two doublings to get there). I also think running a real (non-condensing) filter on a 1GB file is already a pretty unlikely corner case. > But let's queue this and see what happens. Sounds good to me. -Peff
diff --git a/convert.c b/convert.c index 5d0307fc10..94ff837649 100644 --- a/convert.c +++ b/convert.c @@ -731,7 +731,7 @@ static int apply_single_file_filter(const char *path, const char *src, size_t le if (start_async(&async)) return 0; /* error was already reported */ - if (strbuf_read(&nbuf, async.out, len) < 0) { + if (strbuf_read(&nbuf, async.out, 0) < 0) { err = error(_("read from external filter '%s' failed"), cmd); } if (close(async.out)) {