Comment 21 for bug 1278780

Revision history for this message
Steve Langasek (vorlon) wrote : Re: [Bug 1278780] Re: apport takes too long to write crash report, appears to lock up phone

On Fri, Oct 23, 2015 at 01:07:16PM -0000, Martin Pitt wrote:
> Steve Langasek [2015-10-22 18:11 -0000]:
> > > * If we really want to dump, we could investigate into sendfile. I'm not
> > > * entirely sure that it works with data coming in via stdin, but it's
> > > * worth a try as we would avoid the kernel -> userspace copy.

> > This is an interesting suggestion. It would imply requiring a second
> > post-processing stage, to combine this file with the rest of the crash
> > report in proper (compressed, base64-encoded) format;

> How would that help? In any case you first need to put the core dump
> from stdin onto the disk, and that's precisely the bit that we are
> doing now (and not much more) and which takes so long.

The difference is precisely in the putting of the core dump onto the disk.
Today we write it out from apport; that means we copy the data out from the
kernel into userspace, gzip it, base64 encode it, and then hand it back to
the kernel (by writing it to the file). With sendfile(), we would be
directly moving the core to the file of our choosing, *in kernel space*,
without any userspace processing. It's not even necessary that we flush the
disk buffers, so the slow disk writes don't necessarily happen before apport
returns.

This doesn't guarantee that sendfile will actually be faster. But I think
we need to measure this and find out, rather than assuming one way or the
other.