2005-01-09 19:28:08

by John Richard Moser

[permalink] [raw]
Subject: printf() overhead

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

using strace to run a program takes aeons. Redirecting the output to a
file can be a hundred times faster sometimes. This raises question.

I understand that output to the screen is I/O. What exactly causes it
to be slow, and is there a possible way to accelerate the process?
- --
All content of all messages exchanged herein are left in the
Public Domain, unless otherwise explicitly stated.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB4YUhhDd4aOud5P8RAonuAJ0ejEn1+oaiZnJIAGp2kFUyd8pgSwCdFaco
JgKsWYZfEcemGO3mZvL+KZY=
=vWqA
-----END PGP SIGNATURE-----


2005-01-09 19:42:01

by Andre Tomt

[permalink] [raw]
Subject: Re: printf() overhead

John Richard Moser wrote:
> using strace to run a program takes aeons. Redirecting the output to a
> file can be a hundred times faster sometimes. This raises question.
>
> I understand that output to the screen is I/O. What exactly causes it
> to be slow, and is there a possible way to accelerate the process?

The terminal is a major factor; gnome-terminal for example can be
*extremely* slow.

2005-01-09 20:27:40

by Gene Heskett

[permalink] [raw]
Subject: Re: printf() overhead

On Sunday 09 January 2005 14:25, John Richard Moser wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>using strace to run a program takes aeons. Redirecting the output
> to a file can be a hundred times faster sometimes. This raises
> question.
>
>I understand that output to the screen is I/O. What exactly causes
> it to be slow, and is there a possible way to accelerate the
> process? - --

As to what causes the slow, well fonts have to be rendered, and the
screen has to be scrolled, both of which take finite pieces of time.
Displaying the file later just shifts the rendering etc time to
something thats not nearly so noticeable because you can't read that
fast anyway...

--
Cheers, Gene
"There are four boxes to be used in defense of liberty:
soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
99.31% setiathome rank, not too shabby for a WV hillbilly
Yahoo.com attorneys please note, additions to this message
by Gene Heskett are:
Copyright 2005 by Maurice Eugene Heskett, all rights reserved.

2005-01-09 21:16:31

by John Richard Moser

[permalink] [raw]
Subject: Re: printf() overhead

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Andre Tomt wrote:
| John Richard Moser wrote:
|
|> using strace to run a program takes aeons. Redirecting the output to a
|> file can be a hundred times faster sometimes. This raises question.
|>
|> I understand that output to the screen is I/O. What exactly causes it
|> to be slow, and is there a possible way to accelerate the process?
|
|
| The terminal is a major factor; gnome-terminal for example can be
| *extremely* slow.
|

Is there a way to give the data to the terminal and let the program go
while that happens? Or is there an execution path (i.e. terminal says
"WTF NO") that can be missed that way?

- --
All content of all messages exchanged herein are left in the
Public Domain, unless otherwise explicitly stated.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFB4Z8hhDd4aOud5P8RAnhBAJ40RgKIcXdCvhnuHlfZyK60xswjGwCdFef2
rmwEL/yAR74Q96VkpEV6Z2s=
=bpD8
-----END PGP SIGNATURE-----

2005-01-09 21:26:55

by Alan Curry

[permalink] [raw]
Subject: Re: printf() overhead

John Richard Moser writes the following:
>Andre Tomt wrote:
>| John Richard Moser wrote:
>|> using strace to run a program takes aeons. Redirecting the output to a
>|> file can be a hundred times faster sometimes. This raises question.
>|
>| The terminal is a major factor; gnome-terminal for example can be
>| *extremely* slow.
>|
>
>Is there a way to give the data to the terminal and let the program go
>while that happens? Or is there an execution path (i.e. terminal says
>"WTF NO") that can be missed that way?

strace -o tracefile prog & tail -n +1 -f tracefile

2005-01-10 18:39:30

by Denis Vlasenko

[permalink] [raw]
Subject: Re: printf() overhead

On Sunday 09 January 2005 23:16, John Richard Moser wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Andre Tomt wrote:
> | John Richard Moser wrote:
> |
> |> using strace to run a program takes aeons. Redirecting the output to a
> |> file can be a hundred times faster sometimes. This raises question.
> |>
> |> I understand that output to the screen is I/O. What exactly causes it
> |> to be slow, and is there a possible way to accelerate the process?
> |
> |
> | The terminal is a major factor; gnome-terminal for example can be
> | *extremely* slow.
> |
>
> Is there a way to give the data to the terminal and let the program go
> while that happens? Or is there an execution path (i.e. terminal says
> "WTF NO") that can be missed that way?

Buffering is finite. strace output most likely overflow it.

Also while strace may finish already, you won't see it in gnome terminal
until entire strace stdout/stderr is drawn. You will wait anyway. :)
--
vda