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. Appropriate file buffer size

Appropriate file buffer size

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
9 Posts 2 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.
  • D Offline
    D Offline
    Dustin Henry
    wrote on last edited by
    #1

    I'm writing a file manipulation program, and was wondering in your experience what is the most efficient buffer size to load at a time and manipulate. Would this simply be based on the largest chunk of memory I am willing to allocate on the system, or can smaller buffers produce faster results? Speed is important because I could be converting several thousand files at a time. Thanks, Dustin

    D 1 Reply Last reply
    0
    • D Dustin Henry

      I'm writing a file manipulation program, and was wondering in your experience what is the most efficient buffer size to load at a time and manipulate. Would this simply be based on the largest chunk of memory I am willing to allocate on the system, or can smaller buffers produce faster results? Speed is important because I could be converting several thousand files at a time. Thanks, Dustin

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      How much overhead would it be to first iterate the list of files, look for the largest file, and allocate that much memory?


      "A good athlete is the result of a good and worthy opponent." - David Crow

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      D 1 Reply Last reply
      0
      • D David Crow

        How much overhead would it be to first iterate the list of files, look for the largest file, and allocate that much memory?


        "A good athlete is the result of a good and worthy opponent." - David Crow

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        D Offline
        D Offline
        Dustin Henry
        wrote on last edited by
        #3

        The biggest problem would not neccesarily be the overhead, but the allocation itself. What happens if I run accross a 2GB file? I'm actually attemting to write an encryption program, more as an experiment than anything, and do not know the make up of the files I will be opening.

        D 1 Reply Last reply
        0
        • D Dustin Henry

          The biggest problem would not neccesarily be the overhead, but the allocation itself. What happens if I run accross a 2GB file? I'm actually attemting to write an encryption program, more as an experiment than anything, and do not know the make up of the files I will be opening.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Dustin Henry wrote:

          What happens if I run accross a 2GB file?

          Indeed that would be a problem.

          Dustin Henry wrote:

          I'm actually attemting to write an encryption program...

          What does the encryption algorithm require (in terms of input)?


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          D 1 Reply Last reply
          0
          • D David Crow

            Dustin Henry wrote:

            What happens if I run accross a 2GB file?

            Indeed that would be a problem.

            Dustin Henry wrote:

            I'm actually attemting to write an encryption program...

            What does the encryption algorithm require (in terms of input)?


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            D Offline
            D Offline
            Dustin Henry
            wrote on last edited by
            #5

            I am actually using my own random number generator to randomly convert each byte of data based on an initial seed, so the only requirement is that I process the data in order.

            D 1 Reply Last reply
            0
            • D Dustin Henry

              I am actually using my own random number generator to randomly convert each byte of data based on an initial seed, so the only requirement is that I process the data in order.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              Then I don't see why you couldn't allocate a couple of megabytes for that.


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              D 1 Reply Last reply
              0
              • D David Crow

                Then I don't see why you couldn't allocate a couple of megabytes for that.


                "A good athlete is the result of a good and worthy opponent." - David Crow

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                D Offline
                D Offline
                Dustin Henry
                wrote on last edited by
                #7

                So basically the bigger the better then?

                D 1 Reply Last reply
                0
                • D Dustin Henry

                  So basically the bigger the better then?

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  To a point, but you don't want to get so big that you introduce more disk thrashing. Allocating several MB of memory is not usually noticeable with semi-modern machines.


                  "A good athlete is the result of a good and worthy opponent." - David Crow

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  D 1 Reply Last reply
                  0
                  • D David Crow

                    To a point, but you don't want to get so big that you introduce more disk thrashing. Allocating several MB of memory is not usually noticeable with semi-modern machines.


                    "A good athlete is the result of a good and worthy opponent." - David Crow

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    D Offline
                    D Offline
                    Dustin Henry
                    wrote on last edited by
                    #9

                    Great, thanks for your help David.

                    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