[PATCH v2] Single threaded stdio optimization
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Fri Jun 30 15:34:00 GMT 2017
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.
Wilco
More information about the Libc-alpha
mailing list