Re: Network buffering question




Scott McPhillips [MVP] wrote:
Alex Fraser wrote:
I disagree with Scott's suggestion of a large circular buffer. It is
wasteful of memory and a long time ago I found it to have marginally lower
performance than a simpler approach, which goes something like this:

Me too:) I suggested a large buffer, not a large circular buffer. What
I use, and what your code also uses, is what I think of as a "slide
down" buffer, where any remaining message fragment must be copied to the
buffer start if it is too close to the end. Making the buffer large
reduces the frequency of this copying.

--
Scott McPhillips [VC++ MVP]

The alternative is double buffering. First call you use buffer A, parse
the messages, leaving the start of message M. Call again with buffer B
and continue processing by reading the last of buffer A (the start of
the next message) and continuing with buffer B.

If you run multiThreaded, then you can send off the request to fill
buffer B as soon as you get back buffer A. Parsing buffer A while B is
off getting more data.

Ed

.



Relevant Pages

  • Re: Discovering variable types...
    ... >- but I suppose MS expect us to use wrappers ... memory allocations for your variables from disk as well. ... >They most certainly are of fixed size, changing the size of a String ... >>me to keep buffer size and current postion right in the memory block. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Discovering variable types...
    ... >memory it points to is on the heap. ... sequentially reading data, if one is randomly reading records, then a ... >project is what's prompting me to improve disk access. ... from a memory buffer I can do it in about a second. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Multicast Directshow Graph Bridging, COW Rustling, & the Use of Portable Holes in Cartoon Ph
    ... memory to share buffer pools across processes and works pretty well. ... You get two basic Direct Show filters, ... issue each GMF-source a virtual memory alias with COW ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: PCI bus-master and large contiguous memory buffers
    ... I built my scatter gather list in SRAM that was on my device, ... could have done it in system memory had I needed to. ... interrupt when a buffer was filled, the application would save the buffer to ... beginning of the recording I made a device IO control call to my driver. ...
    (microsoft.public.development.device.drivers)
  • Re: PCI bus-master and large contiguous memory buffers
    ... As soon as device reaches the end of the buffer ... Sure, I am developing both PCI adapter and device driver, so, it is ... not afford reinitializing DMA on my device after every transfer. ... x86 CPU memory management structures I never tried to dig into Windows ...
    (microsoft.public.development.device.drivers)