[systemd-devel] [PATCH 2/2] journald: when buffering stdout, allow buffer to grow if needed
Lennart Poettering
lennart at poettering.net
Tue Dec 10 10:28:12 PST 2013
On Tue, 10.12.13 13:22, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:
> > Here is a brief test script that stresses the stdout capture. Run it through
> > systemd-run and watch the CPU usage of the systemd-journal process before and
> > after.
> >
> > #!/usr/bin/env python2
> >
> > data = []
> > for i in range(1000):
> > data.append('abcdefghijklmnopqrstuvwxyz')
> > data.append('%d' % i)
> >
> > print ' '.join(data * 5)
> > print ' '.join(data * 15)
> > print ' '.join(data * 25)
> >
> >
> > src/journal/journald-stream.c | 19 ++++++++++++++++++-
> > 1 file changed, 18 insertions(+), 1 deletion(-)
> >
> > diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
> > index 193d438..890c0bf 100644
> > --- a/src/journal/journald-stream.c
> > +++ b/src/journal/journald-stream.c
> > @@ -236,6 +236,8 @@ static int stdout_stream_line(StdoutStream *s, char *p) {
> > assert_not_reached("Unknown stream state");
> > }
> >
> > +#define STDOUT_BUFFER_MAX 256*1024u
> > +
Please keep defines like this at the top of the file. And also, please
add () around it, so that this never by accident is included in a some
more complex operation where operator ordering would start to matter.
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list