Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Optimizing hard drive write performance

Optimizing hard drive write performance

Scheduled Pinned Locked Moved C / C++ / MFC
performancecom
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TragicComic
    wrote on last edited by
    #1

    I'm working on an application that captures uncompressed video from 2 high resolution (1024x768) video cameras at 30 fps. In order to stream to the hard drive without dropping frames, I need to maintain an average transfer rate of ~47 megabytes per second. The drives I am using are rated to be able to handled a sustained write of 75 megabytes per second all the way to the end. However, simply writing data with fwrite and timing the performance, I am coming no where near the necessary level of performance. If anyone out there has any experience with high performance file writing, I'd love to get some tips/pointers on ways to increase write speed. Adam Kraver www.captivemotion.com

    J P 2 Replies Last reply
    0
    • T TragicComic

      I'm working on an application that captures uncompressed video from 2 high resolution (1024x768) video cameras at 30 fps. In order to stream to the hard drive without dropping frames, I need to maintain an average transfer rate of ~47 megabytes per second. The drives I am using are rated to be able to handled a sustained write of 75 megabytes per second all the way to the end. However, simply writing data with fwrite and timing the performance, I am coming no where near the necessary level of performance. If anyone out there has any experience with high performance file writing, I'd love to get some tips/pointers on ways to increase write speed. Adam Kraver www.captivemotion.com

      J Offline
      J Offline
      James R Twine
      wrote on last edited by
      #2

      I believe the way to get the fastest file throughput is to use Overlapped I/O along with the NO_BUFFERING flag when the file is created/opened with CreateFile(...).  There are some gotchas with buffer size and alignment, but if you are good enough to be streaming real-time video, it is likely nothing that you cannot handle!    Also, just because your drive can go that fast does not mean that your system can.  Other factors (the drive controller being used, any hardware caching, what other stuff your system is doing).    Peace!

      -=- James
      Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
      Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
      See DeleteFXPFiles

      P T 2 Replies Last reply
      0
      • J James R Twine

        I believe the way to get the fastest file throughput is to use Overlapped I/O along with the NO_BUFFERING flag when the file is created/opened with CreateFile(...).  There are some gotchas with buffer size and alignment, but if you are good enough to be streaming real-time video, it is likely nothing that you cannot handle!    Also, just because your drive can go that fast does not mean that your system can.  Other factors (the drive controller being used, any hardware caching, what other stuff your system is doing).    Peace!

        -=- James
        Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
        Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
        See DeleteFXPFiles

        P Offline
        P Offline
        Perspx
        wrote on last edited by
        #3

        Yes, James is correct.. If you are using a SATA disk, it can transfer up to 150MB of data/sec, and a SATA II disk will do up to 300MB of data/sec so you have to be careful with this.. if it is an ATA disk, then you're looking at up to 133MB of data/sec.. FireWire external HDDs can transfer up 800MB of data/sec.. Bearing these in mind also note that Windows schedules other tasks and so it uses the disk(s) for these aswell so writing to a "non-Windows" disk (i.e. a disk which doesnt have the running Windows on it) and a disk which is also not being accessed will improve data-transfer rate.. Also check your motherboard FSB.. this will also affect the speed of data transfer to and from the hard disks.. Hope this helps! --PerspX

        "Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates

        1 Reply Last reply
        0
        • J James R Twine

          I believe the way to get the fastest file throughput is to use Overlapped I/O along with the NO_BUFFERING flag when the file is created/opened with CreateFile(...).  There are some gotchas with buffer size and alignment, but if you are good enough to be streaming real-time video, it is likely nothing that you cannot handle!    Also, just because your drive can go that fast does not mean that your system can.  Other factors (the drive controller being used, any hardware caching, what other stuff your system is doing).    Peace!

          -=- James
          Please rate this message - let me know if I helped or not! * * * If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong!
          Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road!
          See DeleteFXPFiles

          T Offline
          T Offline
          TragicComic
          wrote on last edited by
          #4

          James, thanks for the hint! So far, using CreateFile and WriteFile with NO_BUFFERING, I'm getting the performance I was expecting (and so far, the performance that it looks like I need). Of course, I'm testing this in a small test app, so I'm not sure what the final results will be in the capture app, but the results are quite promising.

          1 Reply Last reply
          0
          • T TragicComic

            I'm working on an application that captures uncompressed video from 2 high resolution (1024x768) video cameras at 30 fps. In order to stream to the hard drive without dropping frames, I need to maintain an average transfer rate of ~47 megabytes per second. The drives I am using are rated to be able to handled a sustained write of 75 megabytes per second all the way to the end. However, simply writing data with fwrite and timing the performance, I am coming no where near the necessary level of performance. If anyone out there has any experience with high performance file writing, I'd love to get some tips/pointers on ways to increase write speed. Adam Kraver www.captivemotion.com

            P Offline
            P Offline
            Paresh Chitte
            wrote on last edited by
            #5

            Programatically you can acheive this by implementing multithreading. Put the code of writing to disk in separate thread. Regards, Paresh.

            T 1 Reply Last reply
            0
            • P Paresh Chitte

              Programatically you can acheive this by implementing multithreading. Put the code of writing to disk in separate thread. Regards, Paresh.

              T Offline
              T Offline
              TragicComic
              wrote on last edited by
              #6

              Before using CreateFile and WriteFile, I had done that, but unfortunately, the performance of fwrite couldn't keep up with my transfer needs (it runs about 1/2 to 1/4 the speed of WriteFile when using unbuffered writes, even when there is no other real load on the CPU).

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups