Bug 1005 - putc() runs slower
Summary: putc() runs slower
Status: RESOLVED WONTFIX
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.3.3
: P2 normal
Target Milestone: ---
Assignee: Uttam Pawar
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-10 21:37 UTC by Uttam Pawar
Modified: 2006-02-13 15:26 UTC (History)
2 users (show)

See Also:
Host: powerpc-linux
Target: powerpc-linux
Build: powerpc-linux
Last reconfirmed:


Attachments
Proposed patch (693 bytes, patch)
2005-06-10 21:46 UTC, Uttam Pawar
Details | Diff
proposed libio-stream lock/unlock patch (881 bytes, patch)
2005-07-11 17:46 UTC, Uttam Pawar
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Uttam Pawar 2005-06-10 21:37:31 UTC
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.
Comment 1 Uttam Pawar 2005-06-10 21:46:06 UTC
Created attachment 516 [details]
Proposed patch
Comment 2 Uttam Pawar 2005-06-24 22:25:58 UTC
Can this patch be verified?
Comment 3 Uttam Pawar 2005-07-11 17:46:18 UTC
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).
Comment 4 Ulrich Drepper 2005-09-23 02:35:13 UTC
This is why there is putc_unlocked.
Comment 5 Geoff Smith 2006-02-13 15:26:34 UTC
(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.