* [PATCH] readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER).
@ 2018-06-04 16:55 Mark Wielaard
2018-06-06 20:34 ` Mark Wielaard
0 siblings, 1 reply; 2+ messages in thread
From: Mark Wielaard @ 2018-06-04 16:55 UTC (permalink / raw)
To: elfutils-devel; +Cc: Mark Wielaard
We only call printf on stdout from one thread, so we don't need internal
stdio locking for stdout.
On my machine eu-readelf -N --debug-dump=info libxul.so > /dev/null
goes from 65 seconds to 63 seconds.
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
src/ChangeLog | 4 ++++
src/readelf.c | 5 +++++
2 files changed, 9 insertions(+)
diff --git a/src/ChangeLog b/src/ChangeLog
index cc12d83..19f4210 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2018-06-04 Mark Wielaard <mark@klomp.org>
+
+ * readelf.c (main): Call __fsetlocking (stdout, FSETLOCKING_BYCALLER).
+
2018-05-31 Mark Wielaard <mark@klomp.org>
* readelf.c (print_debug_units): Print the dwo name and id when
diff --git a/src/readelf.c b/src/readelf.c
index 0725313..a578b27 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -35,6 +35,8 @@
#include <locale.h>
#include <stdarg.h>
#include <stdbool.h>
+#include <stdio.h>
+#include <stdio_ext.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
@@ -310,6 +312,9 @@ static void dump_archive_index (Elf *, const char *);
int
main (int argc, char *argv[])
{
+ /* We use no threads here which can interfere with handling a stream. */
+ (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER);
+
/* Set locale. */
setlocale (LC_ALL, "");
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER).
2018-06-04 16:55 [PATCH] readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER) Mark Wielaard
@ 2018-06-06 20:34 ` Mark Wielaard
0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2018-06-06 20:34 UTC (permalink / raw)
To: elfutils-devel
On Mon, Jun 04, 2018 at 06:54:53PM +0200, Mark Wielaard wrote:
> We only call printf on stdout from one thread, so we don't need internal
> stdio locking for stdout.
>
> On my machine eu-readelf -N --debug-dump=info libxul.so > /dev/null
> goes from 65 seconds to 63 seconds.
Pushed to master.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-06 20:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-04 16:55 [PATCH] readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER) Mark Wielaard
2018-06-06 20:34 ` Mark Wielaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).