On 2015-09-28 5:41 PM, Gregory Szorc wrote:
When writing thousands of files in rapid succession, this 1+ms pause
(assuming synchronous I/O) piles up. Assuming a 1ms pause, writing 100,000
files spends 100s in CloseFile()! The process profile also shows the bulk
of the time in CloseFile(), so this is a real hot spot.
There is no CloseFile() on Windows. Did you mean CloseHandle()?
The reason I'm asking is that CloseHandle() can close various types of
kernel objects, and if that is showing up in profiles, it's worth to
verify that the handle passed to it is actually coming from CreateFile(Ex).
Closing handles on a background thread doesn't help with performance if
you're invoking sub-processes that need to close a handle and wait for
the operation to finish. It would help if you provided more details on
the constraints you're dealing with, e.g., where do these handles come
from? Are they being created by one long running process or by several
short lived ones? etc. Another idea to experiment with is leaking the
handles and letting the kernel close them for you when your process is
terminated. I _think_ (but I'm not sure) that won't count towards the
handle of the process to become signaled so if you're spawning a process
that needs to close the file and wait for that to finish, that may be
faster.
On the topic of performance on Windows (but not directly related to your
question), beware of the ~60ms CreateProcess overhead
<https://llvm.org/bugs/show_bug.cgi?id=20253#c4>. Depending on the
context, one could kill both of these perf issues with one stone by
doing as many of the file manipulation in one process as you can, and
closing the handles on a background thread.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform