Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7030311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:39:14+00:00 2026-05-28T00:39:14+00:00

I’m working on a native C++/Win32/MFC app on Windows 7. I’m using CFile to

  • 0

I’m working on a native C++/Win32/MFC app on Windows 7. I’m using CFile to open a file stored on a remote server (with the flags, CFile::modeRead | CFile::shareDenyWrite). The server is running Windows Server 2008 and I’m accessing the file on a shared drive via regular windows file sharing. Once I open the file, I’m reading it as described below.

First, I’m seeking to multiple locations in the file (10 locations) and reading small (128 byte) sections. Then, I’m seeking to the beginning and reading sequentially through the entire file.

What I noticed is that doing the above was MUCH slower than just opening the file and reading through it. The initial random seeks and sampling is very quick, almost instant even with a large file. What’s interesting is that even though this is quick, the next part, scanning through the file is very slow when compared with just scanning through it without the initial random access.

In trying to figure out what was going on I pulled up performance monitor and watched the network traffic. If I just do the sequential read through the file, I’m getting 3.5MB/s download over the wireless adapter. If I first randomly seek around, then sequentially read through I’m only getting 300kB/s during the sequential read.

The solution was to close and re-open the file after doing the random access part. When I did this, the sequential read sped right up.

So it seems that doing the random access reads (the seek and read) did something on the server which then caused the sequential read to be slow. I’m wondering, does anyone know for sure whats going on here and what the actual cause is of the behavior I’m seeing? Although I have a fix for it I’d like to better understand what’s going on under the hood to cause this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:39:15+00:00Added an answer on May 28, 2026 at 12:39 am

    Mooing Duck‘s comment is right on. The operating system starts out assuming sequential access as a ‘soft’ option — enabled until proven harmful. But the random accesses causes the read ahead to make performance worse, and the ‘smart’ caching behavior turns read ahead off.

    You would think a few sequential accesses would cause Windows to turn it back on. But unfortunately, the flag is no longer ‘soft’ at this point. Windows considers random access proven from then on, just as if you had forced it into that mode.

    You can pass CreateFile the FILE_FLAG_SEQUENTIAL_SCAN option to force it to keep read ahead on no matter what. But your re-open solution is probably about as good as anything. And it’s about the only way if you don’t call CreateFile directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.