{"id":31633,"date":"2006-04-06T10:00:13","date_gmt":"2006-04-06T10:00:13","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2006\/04\/06\/its-more-efficient-when-you-buy-in-bulk\/"},"modified":"2006-04-06T10:00:13","modified_gmt":"2006-04-06T10:00:13","slug":"its-more-efficient-when-you-buy-in-bulk","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20060406-13\/?p=31633","title":{"rendered":"It&#039;s more efficient when you buy in bulk"},"content":{"rendered":"<p>The Windows&nbsp;XP kernel does not turn every call into <code>FindNextFile<\/code> into a packet on the network. Rather, the first time an application calls <code>FindNextFile<\/code>, it issues a bulk query to the server and returns the first result to the application. Thereafter, when an application calls <code>FindNextFile<\/code>, it returns the next result from the buffer. If the buffer is empty, then <code>FindNextFile<\/code> issues a new bulk query to re-fill the buffer.\n This is a significant performance improvement when reading the entire contents of large directories because it reduces the number of round trips to the server. We&#8217;ll see next time that the gain can be quite significant on certain types of servers.<\/p>\n<p> But it also means that the suggestion of &#8220;Well, why not ask for 101 files and see if you get an error&#8221; won&#8217;t help any. (Actually I think the magic number was really 128, not 100, but let&#8217;s keep calling it 100 since that&#8217;s what I started with.) The number 100 was not some magic value on the server. That number was actually our own unwitting choice: The bulk query asks for 100 files at a time! <a href=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2006\/03\/31\/565878.aspx#568106%20\"> If we changed the bulk query to ask for 101 files, then the problem would just appear at the 102nd file<\/a>. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Windows&nbsp;XP kernel does not turn every call into FindNextFile into a packet on the network. Rather, the first time an application calls FindNextFile, it issues a bulk query to the server and returns the first result to the application. Thereafter, when an application calls FindNextFile, it returns the next result from the buffer. If [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-31633","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>The Windows&nbsp;XP kernel does not turn every call into FindNextFile into a packet on the network. Rather, the first time an application calls FindNextFile, it issues a bulk query to the server and returns the first result to the application. Thereafter, when an application calls FindNextFile, it returns the next result from the buffer. If [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/31633","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=31633"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/31633\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=31633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=31633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=31633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}