cygrunsrv + sshd + rsync = 20 times too slow -- throttled?

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Oct 18 10:51:37 GMT 2021


Hi Takashi, Hi Ken,

first of all, thanks for keeping at it!

On Sep 24 00:03, Takashi Yano wrote:
> On Thu, 23 Sep 2021 09:03:13 -0400
> Ken Brown wrote:
> > On 9/23/2021 4:26 AM, Takashi Yano wrote:
> > > * Make temporary_query_hdl() faster.
> > 
> > Thanks!  Again, I'm not familiar with the Windows functions that you used, so 
> > Corinna should review this too when she returns.
> > 
> > I have one question:
> > 
> > The documentation at 
> > https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-enumprocesses 
> > says, "There is no indication given when the buffer is too small to store all 
> > process identifiers. Therefore, if lpcbNeeded equals cb, consider retrying the 
> > call with a larger array."
> > 
> > Does this mean that EnumProcesses could return TRUE even if the buffer is too small?
> 
> Ah, right. Thanks for pointing out that mistake.
> I have fixed that.

The patch looks basically ok, but we shouldn't use PSAPI calls inside
Cygwin.  I'm a bit fuzzy on the details, but we had some problems with
PSAPI way back when.

One of them, prominently, is the fact that the entry points have changed
in the past.  EnumProcess from psapi.dll is now k32_EnumProcess from
kernel32.dll or whatever, since the headers are using PSAPI_VERSION 2 as
default.  Linking against that will break Vista.  If you change this to
PSAPI_VERSION 1, OTOH, you will have to add the psapi symbols to
autoload.cc.

Why don't you just use winpids, as in:

  winpids pids;
  pids.set (true);
  for (int i = 0; i < pids.npids; ++i)
    ...
  pids.reset ();

This will use NtQuerySystemInformation (SystemProcessInformation) under
the hood.  Of course, winpids adds a bit of unnecessary overhead by
checking for procinfo stuff, so maybe you may want to use
NtQuerySystemInformation (SystemProcessInformation) directly and
just copy/paste the minimally required code from the `else' branch in
winpids::enum_processes.


Thanks,
Corinna


More information about the Cygwin-developers mailing list