CreateFile API 的性能下降

发布于 2024-07-23 11:33:42 字数 257 浏览 4 评论 0原文

我有一个应用程序可以从库中恢复大量数据。 我们正在使用 Windows Server 2003。随着过程的进展,我们看到性能下降。 我为 4 个主要任务添加了一些性能计数器:创建文件、从库中读取、写入数据、关闭文件。 我们正在恢复数百万个文件。 我观察到,随着进程的进展,createfile API 的性能正在下降。 其他操作一致。

有什么想法可能导致这种情况吗?

预先感谢您的所有答案/建议。

问候, 布山

I have an application that is restoring lots of data from a library. We are using Windows server 2003. As the process progresses we are seeing performance degradation. I added some performance counters for 4 of my major tasks, Create file, Read from library, WriteData, Close file. We are restoring millions of files.
What I observed is that the performance of createfile API is degrading as the process progresses. The other operations are consistent.

Any ideas what could be causing this?

Thanks in advance for all the answers/suggestions.

Regards,
Bhushan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

还给你自由 2024-07-30 11:33:42

文件系统是NTFS吗? 数百万个文件是否位于同一目录中,它们是否具有相似的名称? 来自 有关 NTFS 内部结构的 technet 文章

如果文件夹中有大量文件(300,000 个或更多),并且这些文件的文件名较长且首字符相同,则创建文件所需的时间会增加。 出现这种增加是因为 NTFS 将短文件名基于长文件名的前六个字符。 在包含超过 300,000 个文件的文件夹中,在 NTFS 使用所有与长文件名相似的 8.3 名称后,短文件名开始发生冲突。 生成的短文件名与现有短文件名重复冲突会导致 NTFS 重新生成短文件名 6 到 8 次。

您可以使用命令行实用程序“fsutil”查询此行为:

fsutil behavior query disable8dot3

Is the file system NTFS? Are the millions of files going to the same directory, and do they have similar names? From the technet article on NTFS internals:

If you have a large number of files (300,000 or more) in a folder, and the files have long file names with the same initial characters, the time required to create the files increases. The increase occurs because NTFS bases the short file name on the first six characters of the long file name. In folders with more than 300,000 files, the short file names start to conflict after NTFS uses all of the 8.3 names that are similar to the long file names. Repeated conflicts between a generated short file name and existing short file names cause NTFS to regenerate the short file name from 6 to 8 times.

You can query this behavior using the command line utility 'fsutil':

fsutil behavior query disable8dot3
情泪▽动烟 2024-07-30 11:33:42

您能否提供一些有关库数据存储位置以及文件创建位置的信息?

例如,如果您将所有输出文件创建到同一目录中,您可能会发现 CreateFile 速度变慢,因为它需要检查越来越多的文件名是否存在冲突。

Can you provide some information about where the library data is stored, and where the files are being created?

For example, if you are creating all the output files into the same directory you may be finding that CreateFile is slowing down because it needs to check against more and more file names for collisions.

清风不识月 2024-07-30 11:33:42

可能与系统缓存冲突? 您可以查看 CreateFile 文档中的“缓存行为”部分。

Possibly fighting the system cache? You might look at the Caching Behavior section in the documentation to CreateFile.

苹果你个爱泡泡 2024-07-30 11:33:42

我的心灵调试器说你正在泄漏句柄。 您是否正在 CloseHandle 处理您正在 CreateFile 处理的所有调用?

My psychic debugger says you're leaking handles. Are you CloseHandle'ing all of those calls you're CreateFile'ing?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文