Re: [PATCH v2 next 03/11] tools/nolibc/printf: Add buffering to vfprintf() callback.

From: David Laight

Date: Tue Feb 17 2026 - 06:52:31 EST


On Mon, 16 Feb 2026 20:07:35 +0100
Thomas Weißschuh <linux@xxxxxxxxxxxxxx> wrote:

> On 2026-02-07 23:36:51+0000, David Laight wrote:
> > On Sat, 7 Feb 2026 20:29:34 +0100
> > Willy Tarreau <w@xxxxxx> wrote:
> >
> > > On Fri, Feb 06, 2026 at 07:11:13PM +0000, david.laight.linux@xxxxxxxxx wrote:
> > > > From: David Laight <david.laight.linux@xxxxxxxxx>
> > > >
> > > > Add per-call buffering to the vprintf() callback.
> > > > While this adds some extra code it will speed things up and
> > > > makes a massive difference to anyone looking at strace output.
> > >
> > > This patch alone adds more than 200 extra bytes to the smallest binary
> > > for something that was never expressed as a need by users:
> > >
> > > $ size hello-patch*
> > > text data bss dec hex filename
> > > 1859 48 24 1931 78b hello-patch1
> > > 2071 48 24 2143 85f hello-patch2
> > >
> > > I doubt it would make sense to have a build option to choose this.
> > > Or alternately one could decide do disable it when __OPTIMIZE_SIZE__
> > > is defined. I just tried quickly and it does the job:
> >
> > That probably makes sense.
> > For anything non-trivial the extra size is noise.
> > Actually is would be easier to read with a single #if covering the
> > whole lot.
>
> While I like the slimmer strace output, the added complexity, including
> a different implementation for __OPTIMIZE_SIZE__ is a bit scary.
> Could we leave this out for now and work on it on its own?

I might move it later in the patch series.

I plan to add a #define that can select some of the extra features.
Basically making bits from 'flags' makes the compiler optimise the
associated code away - so 0 => no options and -1 => all options.
But you also set '-' (with the quotes) to get just left alignment
or '-', '.' to get left alignment and zero pad.

I can use a character (that misses a flag -eg 'b') to enable buffering.

I thought about being able to disable features, but the requirement
is only really to make small programs very small (but they may want
one extra bit), the 400(ish) bytes that everything adds isn't that
significant for anything non-trivial.
(Oh and that is 400 for this version, with 'nothing' it is smaller
that the old version).

David

>
>
> Thomas
>