Bonnie application runs slower with nptl configured glibc library. This application calls putc() in a tight loop. While using nptl configured libc (static or dynamic version), causes the worst runtime performance.
Created attachment 516 [details] Proposed patch
Can this patch be verified?
Created attachment 551 [details] proposed libio-stream lock/unlock patch patch has added a check in _IO_putc(), _IO_getc(), putchar() and getchar() library call if the calling app is single threaded or not. If it is single threaded at the time of call to any of the above call, then call unlocked version of library functions. This make sense because, when an application ( not multithreaded) calls putc() or any of the above call, thread of executation is going to remain single, till we come back from the call and execute pthread_create() and so on. There is no chance of new thread getting created while application is in any of the above mentioned call. I've built and ran complete glibc testsuite with the above patch and did not see any new failures but saw an improvement in the performance numbers (obviously).
This is why there is putc_unlocked.
(In reply to comment #4) > This is why there is putc_unlocked. We can't very well advise someone to substitute putc_unlocked() for putc(). Suppose some sap did this, and then years later the code gets reused in a threaded application -- this well-intentioned advice could cause very hard-to- find problems.