public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* time:ing non-cygwin apps
@ 2001-09-05  3:57 Jesper Eskilson
  0 siblings, 0 replies; 5+ messages in thread
From: Jesper Eskilson @ 2001-09-05  3:57 UTC (permalink / raw)
  To: Cygwin Mailinglist

Hi,

I'm trying to get some useful information about the execution time of
non-cygwin app. To illustrate, run the following shell-script:

--[ cygwintime.sh ]--

#!/bin/bash

cat > foo.c <<EOF
int main() {
  int i;
  for (i=0; i < 1000000000; i++);
}
EOF

gcc foo.c -o foo-cygwin
gcc -mno-cygwin foo.c -o foo-native

time ./foo-cygwin
time ./foo-native

--[ ... ]--

On my machine, I get the following output:

[0][SEBASTIAN] ~ -> ./cygwintime.sh

real    0m4.426s
user    0m4.346s
sys     0m0.010s

real    0m4.006s
user    0m0.010s
sys     0m0.010s
[0][SEBASTIAN] ~ ->


Note that the -mno-cygwin application takes almost no user or sys
time, but several seconds real time, as if the time command is unable
to report the time of non-cygwin applications. 

Naturally, I'd like to get similar results in both cases. Is there any
way I can get round this? (Is it a bug or a feature? ;-))

/Jesprer
-- 
-------------------------------------------------------------------------
Jesper Eskilson                                         jojo@virtutech.se
Virtutech                                         http://www.virtutech.se
-------------------------------------------------------------------------

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: time:ing non-cygwin apps
  2001-09-05  9:06 Troy Noble
@ 2001-09-05  9:09 ` Christopher Faylor
  0 siblings, 0 replies; 5+ messages in thread
From: Christopher Faylor @ 2001-09-05  9:09 UTC (permalink / raw)
  To: cygwin

On Wed, Sep 05, 2001 at 10:06:45AM -0600, Troy Noble wrote:
>>Did you actually READ the code?  It is easy enough to download and
>>inspectable with any simple text editor.  It is not brain surgey or
>>rocket science! It's just C++ code!
>
>>Is this what you were expecting?  :-))
>
>>But, seriously, FWIW, everything you said was 100% correct.  You're
>>impressed by the way cygwin handles exec and I'm impressed that you
>>figured it out.  Thank you for the cogent explanation.
>
>Ugh.  Boy you scared me there for a second.

Sorry.  I couldn't resist.

>I think I might join the developers list (finally) and then I won't
>have to bother the world with my proposed fixes.
>
>Definitely need to fill out an assignment form as you suggest...
>unless I miss my guess, it could get into a bit more than a few lines
>of code.

I'm not trying to discourage you from the developers list but you can
always send patches to cygwin-patches, too.  You can subscribe to that
group without approval.

I will approve your subscription to cygwin-developers, if you decide
that's the way to go, though.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: time:ing non-cygwin apps
@ 2001-09-05  9:06 Troy Noble
  2001-09-05  9:09 ` Christopher Faylor
  0 siblings, 1 reply; 5+ messages in thread
From: Troy Noble @ 2001-09-05  9:06 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

> Did you actually READ the code?  It is easy enough to download and
> inspectable with any simple text editor.  It is not brain surgey or
> rocket science!  It's just C++ code!

> Is this what you were expecting?  :-))

> But, seriously, FWIW, everything you said was 100% correct.  You're
> impressed by the way cygwin handles exec and I'm impressed that you
> figured it out.  Thank you for the cogent explanation.

Ugh.  Boy you scared me there for a second.  I thought I was off in
the weeds again.  Wouldn't be the first time of course ;->

I think I might join the developers list (finally) and then I won't
have to bother the world with my proposed fixes.

Definitely need to fill out an assignment form as you suggest...
unless I miss my guess, it could get into a bit more than a few
lines of code.

Troy

-----Original Message-----
From: Christopher Faylor [ mailto:cgf@redhat.com ]
Sent: Wednesday, September 05, 2001 9:43 AM
To: cygwin@cygwin.com
Subject: Re: time:ing non-cygwin apps


On Wed, Sep 05, 2001 at 09:24:27AM -0600, Troy Noble wrote:
>[snip]
>I won't go into more details now... I don't want to get flamed
>too badly at this point.  I have a couple of ideas regarding how
>to overcome this issue, but want to do some more experimenting
>before I propose them to the developers or submit a patch or whatnot.
>Hopefully if any of the above is incorrect the cygwin developers
>can set me straight... since they've got much more history with this
>stuff than I do.

Sigh.  What in the WORLD are you talking about?

Did you actually READ the code?  It is easy enough to download and
inspectable with any simple text editor.  It is not brain surgey or
rocket science!  It's just C++ code!

(Is this what you were expecting?  :-))

But, seriously, FWIW, everything you said was 100% correct.  You're
impressed by the way cygwin handles exec and I'm impressed that you
figured it out.  Thank you for the cogent explanation.

I look forward to your patch.  If your patch is going to be substantial,
however, you might want to check out the contributing link at
http://cygwin.com/ .  You don't have to join cygwin-developers
if you are not interested in becoming a full-time contributor but
you might have to fill out an assignment form if your patch is more
than a few lines.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: time:ing non-cygwin apps
  2001-09-05  8:24 Troy Noble
@ 2001-09-05  8:42 ` Christopher Faylor
  0 siblings, 0 replies; 5+ messages in thread
From: Christopher Faylor @ 2001-09-05  8:42 UTC (permalink / raw)
  To: cygwin

On Wed, Sep 05, 2001 at 09:24:27AM -0600, Troy Noble wrote:
>[snip]
>I won't go into more details now... I don't want to get flamed
>too badly at this point.  I have a couple of ideas regarding how
>to overcome this issue, but want to do some more experimenting
>before I propose them to the developers or submit a patch or whatnot.
>Hopefully if any of the above is incorrect the cygwin developers
>can set me straight... since they've got much more history with this
>stuff than I do.

Sigh.  What in the WORLD are you talking about?

Did you actually READ the code?  It is easy enough to download and
inspectable with any simple text editor.  It is not brain surgey or
rocket science!  It's just C++ code!

(Is this what you were expecting?  :-))

But, seriously, FWIW, everything you said was 100% correct.  You're
impressed by the way cygwin handles exec and I'm impressed that you
figured it out.  Thank you for the cogent explanation.

I look forward to your patch.  If your patch is going to be substantial,
however, you might want to check out the contributing link at
http://cygwin.com/ .  You don't have to join cygwin-developers
if you are not interested in becoming a full-time contributor but
you might have to fill out an assignment form if your patch is more
than a few lines.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: time:ing non-cygwin apps
@ 2001-09-05  8:24 Troy Noble
  2001-09-05  8:42 ` Christopher Faylor
  0 siblings, 1 reply; 5+ messages in thread
From: Troy Noble @ 2001-09-05  8:24 UTC (permalink / raw)
  To: 'Jesper Eskilson', Cygwin Mailinglist

The stats time.exe is giving you is likely the CPU time consumed
by the hidden bash.exe rather than the time consumed by your own
native win32 app.  Which would explain the discrepancy in the result.

Let me explain...

As you said, when you compile with -mno-cygwin, you get a native
win32 executable.  It doesn't depend on cygwin1.dll

The behavior I've observed is that when bash runs a native win32
process, it does a fork/exec maneuver just like it normally would
to start any child process.  The result is that you get a hidden
bash.exe process.  I say "hidden" because it doesn't show up in a
"ps" but an extra bash.exe does show up in WinNT/Win2k Task Manager.
Furthermore, a "ps" reveals that the native win32 program you just
started gets assigned PID=WINPID=the-pid-of-the-hidden-bash.exe

I have studied cygwin's fork/exec code and it looks like this
is the clever way that cygwin gets around the fact that Win32's
CreateProcess and friends don't really support the idea of
a process changing its identity midstream... which is exactly
what exec, execvp, etc. accomplish for you on Unix.
It's really quite ingenious how cygwin does it.  I am impressed.

But it makes for a few strange interactions with native win32 apps,
because you always have this hidden bash.exe process that is sort
of a proxy between the parent and child.
The time.exe thing you are seeing is only one of them.  Another odd
symptom is that when the "hidden" bash.exe gets a SIGINT from its
parent it terminates your native win32 app before it gets a
chance to run its CTRL-C and CTRL-BREAK handler (or signal handler
if you tried to use that approach), which is bad if you've got
some cleanup code in your native win32 app that needs to happen
before the process exits.  Or if you're running Sun's
JVM which attempts to dump a stack trace when it gets a
CTRL-BREAK on the console.

I won't go into more details now... I don't want to get flamed
too badly at this point.  I have a couple of ideas regarding how
to overcome this issue, but want to do some more experimenting
before I propose them to the developers or submit a patch or whatnot.
Hopefully if any of the above is incorrect the cygwin developers
can set me straight... since they've got much more history with this
stuff than I do.

"I am not a cygwin developer or maintainer, just an interested
user."  Thought I should clarify that lest you think I was
speaking no behalf of anyone on the cygwin list besides myself ;->

Troy

-----Original Message-----
From: Jesper Eskilson [ mailto:jojo@virtutech.se ]
Sent: Wednesday, September 05, 2001 4:55 AM
To: Cygwin Mailinglist
Subject: time:ing non-cygwin apps



Hi,

I'm trying to get some useful information about the execution time of
non-cygwin app. To illustrate, run the following shell-script:

--[ cygwintime.sh ]--

#!/bin/bash

cat > foo.c <<EOF
int main() {
  int i;
  for (i=0; i < 1000000000; i++);
}
EOF

gcc foo.c -o foo-cygwin
gcc -mno-cygwin foo.c -o foo-native

time ./foo-cygwin
time ./foo-native

--[ ... ]--

On my machine, I get the following output:

[0][SEBASTIAN] ~ -> ./cygwintime.sh

real    0m4.426s
user    0m4.346s
sys     0m0.010s

real    0m4.006s
user    0m0.010s
sys     0m0.010s
[0][SEBASTIAN] ~ ->


Note that the -mno-cygwin application takes almost no user or sys
time, but several seconds real time, as if the time command is unable
to report the time of non-cygwin applications. 

Naturally, I'd like to get similar results in both cases. Is there any
way I can get round this? (Is it a bug or a feature? ;-))

/Jesprer
-- 
-------------------------------------------------------------------------
Jesper Eskilson                                         jojo@virtutech.se
Virtutech                                         http://www.virtutech.se
-------------------------------------------------------------------------

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-09-05  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-05  3:57 time:ing non-cygwin apps Jesper Eskilson
2001-09-05  8:24 Troy Noble
2001-09-05  8:42 ` Christopher Faylor
2001-09-05  9:06 Troy Noble
2001-09-05  9:09 ` Christopher Faylor

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).