UNC path pointing to local directory much slower than local access

后端 未结 1 1094
时光取名叫无心
时光取名叫无心 2021-02-14 17:57

Some code I\'m working with occasionally needs to refer to long UNC paths (e.g. \\\\?\\UNC\\MachineName\\Path), but we\'ve discovered that no matter where the directory is locat

1条回答
  •  不思量自难忘°
    2021-02-14 18:26

    This doesn't surprise me. You're writing/reading a fairly small amount of data, so the file system cache is probably minimizing the impact of the physical disk I/O; basically, the bottleneck is going to be the CPU. I'm not certain whether the traffic will be going via the TCP/IP stack or not but at a minimum the SMB protocol is involved. For one thing that means the requests are being passed back and forth between the SMB client process and the SMB server process, so you've got context switching between three distinct processes, including your own. Using the local file system path you're switching into kernel mode and back but no other process is involved. Context switching is much slower than the transition to and from kernel mode.

    There are likely to be two distinct additional overheads, one per file and one per kilobyte of data. In this particular test the per file SMB overhead is likely to be dominant. Because the amount of data involved also affects the impact of physical disk I/O, you may find that this is only really a problem when dealing with lots of small files.

    0 讨论(0)
提交回复
热议问题