git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Sleep 1 millisecond in poll() to avoid busy wait

From
Erik Faye-Lund <kusmabite@gmail.com>
Date
Apr 28, 2014, 09:07 UTC
Message-ID
<CABPQNSaC30p7TEOvc85u=+skjrFj17182vWWSL=QNVuvzVFE=w@mail.gmail.com>
In-Reply-To
<20140428083931.GA10257@camelia.ucw.cz>
On Mon, Apr 28, 2014 at 10:39 AM, Stepan Kasal <kasal@ucw.cz> wrote:
Show 31 quoted lines
> From: theoleblond <theodore.leblond@gmail.com>
> Date: Wed, 16 May 2012 06:52:49 -0700
>
> I played around with this quite a bit. After trying some more complex
> schemes, I found that what worked best is to just sleep 1 millisecond
> between iterations. Though it's a very short time, it still completely
> eliminates the busy wait condition, without hurting perf.
>
> There code uses SleepEx(1, TRUE) to sleep. See this page for a good
> discussion of why that is better than calling SwitchToThread, which
> is what was used previously:
> http://stackoverflow.com/questions/1383943/switchtothread-vs-sleep1
>
> Note that calling SleepEx(0, TRUE) does *not* solve the busy wait.
>
> The most striking case was when testing on a UNC share with a large repo,
> on a single CPU machine. Without the fix, it took 4 minutes 15 seconds,
> and with the fix it took just 1:08! I think it's because git-upload-pack's
> busy wait was eating the CPU away from the git process that's doing the
> real work. With multi-proc, the timing is not much different, but tons of
> CPU time is still wasted, which can be a killer on a server that needs to
> do bunch of other things.
>
> I also tested the very fast local case, and didn't see any measurable
> difference. On a big repo with 4500 files, the upload-pack took about 2
> seconds with and without the fix.
> ---
>
> This is one of the patches that lives in msysGit, could it be
> accepted upstream?
> It modifies the Windows compat function only.

compat/poll/poll.c comes from Gnulib, so it would be better to submit the patch there and update.

Previous: Stepan KasalNext: Stepan Kasal
Message 2 of 18 in “Sleep 1 millisecond in poll() to avoid busy wait”
  1. Sleep 1 millisecond in poll() to avoid busy waitStepan Kasal, Apr 28, 2014
  2. Erik Faye-LundApr 28, 2014
  3. Stepan KasalApr 28, 2014
  4. poll/select: prevent busy-waitingStepan Kasal, Apr 28, 2014
  5. Erik Faye-LundApr 28, 2014
  6. Windows: Always normalize paths to Windows-styleStepan Kasal, Apr 28, 2014
  7. Stepan KasalApr 28, 2014
  8. Heiko VoigtMay 7, 2014
  9. Junio C HamanoMay 7, 2014
  10. Stepan KasalMay 8, 2014
  11. Junio C HamanoMay 8, 2014
  12. Revert "submodules: fix ambiguous absolute paths under Windows"Stepan Kasal, May 8, 2014
  13. Johannes SixtApr 28, 2014
  14. Sleep 1 millisecond in poll() to avoid busy waitStepan Kasal, Apr 28, 2014
  15. Erik Faye-LundApr 28, 2014
  16. Junio C HamanoApr 28, 2014
  17. Stepan KasalApr 29, 2014
  18. Junio C HamanoApr 29, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.