[PATCH v2] Single threaded stdio optimization
Torvald Riegel
triegel@redhat.com
Fri Jun 30 16:03:00 GMT 2017
On Fri, 2017-06-30 at 15:34 +0000, Wilco Dijkstra wrote:
> Torvald wrote:
> >
> > What's interesting here is that your high-level optimization is faster
> > than doing the single-thread check in the low-level lock (x86 has it
> > already in the low-level lock).
>
> Have you ever looked at the generated code for eg. getc?
> Each lock does a lot of work even with the low level lock bypass
> optimization. It still does several branches, reads and writes, and
> this is repeated twice for the lock and unlock. A single branch bypassing
> all that is obviously going to be much faster...
>
> And interestingly when you remove the low level lock optimization,
> multithreaded code will run faster too as it no longer needs to do the
> extra checks for the single-threaded case.
I have always argued that we should do this kind of optimization in the
clients, so at the higher levels. So we are in agreement here :)
More information about the Libc-alpha
mailing list