This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ls.exe slow down in cygwin 1.3.13

At 02:24 PM 6/30/2003 +0800, Carlo Florendo wrote:

>Last November 2002, I've upgraded cygwin and encountered a variation in
the behaviour of ls.  ls, when invoked as "ls -l" takes a
>bit longer to execute than the previous cygwin version.  (I've attached
the output of cygehck.)  I haven't upgraded cygwin since
>November 2002 last year since I'm content with my installation now.  The
current variation in the behaviour of ls is not really a
>problem but I'd be glad if I could let it behave as it used to.

I have asked Carlo to run a special version of ls and then a short
test program to isolate the problem. Here is the main part of the test code

     i = lstat(".", &buf);
     printf("%d\n", i);
     i = gettimeofday (&timeval, NULL);
     printf("%d\n", i);

and here is a part of strace
  179   46656 [main] a 1472 fstat64: 0 = fstat (1, 0x22E8A8)
  242   46898 [main] a 1472 writev: writev (1, 0x22FDE8, 1)
  116   47014 [main] a 1472 fhandler_base::write: binary write
  118   47132 [main] a 1472 fhandler_base::write: 2 = write (0xA042998, 2)
  102   47234 [main] a 1472 writev: 2 = write (1, 0x22FDE8, 1), errno 0
1981327 2028561 [main] a 1472 writev: writev (1, 0x22FE18, 1)
  220 2028781 [main] a 1472 fhandler_base::write: binary write
  132 2028913 [main] a 1472 fhandler_base::write: 2 = write (0xA042998, 2)
  108 2029021 [main] a 1472 writev: 2 = write (1, 0x22FE18, 1), errno 0 

It shows that there is a 2 s delay in gettimeofday. My hunch is that it
occurs in, in the part of hires_ms::prime () that raises then 
lowers the thread priority.
Windows has a tendency to penalize threads that just "enjoyed a good time",
compared to their current priority. Why it occurs on Carlo's system, 
I don't know.

The reason for the changes of priority is to try to insure that there is 
little delay between the calls to timeGetTime and to 
GetSystemTimeAsFileTime. Increasing the priority helps but does not make 
guarantees. Perhaps a better way would be something like

timeGetTime(& start);
for (i = 0; i < "whatever"; i++) {
  timeGetTime(& end);
  if (end - start <= "1 ms") break;
  start = end;
i.e. repeat the calls until they all occur very close together.

One can also add bells and whistles, for example always letting i run to
"whatever", recording the various times, and using the results from the
fastest trip through the loop.

Another possibility is to do a robust initialization only when starting 
cygwin and record the values in the cygheap for use by future processes.
This would also prevent an (unlikely) race between several threads running
hires_Xs::prime simultaneously.  


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]