R
Robert
In my current project using memory streams gives about a 3x improvement
in throughtput versus a standard FileStream. I am reading fixed length records
from files.
This parallelizes nicely, since I do large atomic disk reads of the entire
file into a memory stream, letting the disk do sequential reads for each file.
With 2 worker threads, this works great. Triple the throughput..
But with 4 worker threads Out of Memory exceptions
start popping up. Currently just doing a try/catch/ Sleep/retry on these...
This lets some of the other threads finish thier bigger files, allowing
memory to be released.
This all works to some degree just with degraded performance (idled cores)
when a series of big files are encountered.
So, to the question:
Has anyone seen an implementation of a ForwardOnlyMemoryStream?
This would be the same as a memory stream, except that there would
be a Trim Method. Everything before the current StreamPosition would
be released from memory. I would call this after every 100KB of records
are read maybe.
The benefit would be that as each thread loads a big file, it will release
memory slowly and consistently, instead of one big release when the file
is done. This would allow better scaling without having to idle some cores
waiting for RAM to become available.
Sadly, 64 bit is not common yet..
in throughtput versus a standard FileStream. I am reading fixed length records
from files.
This parallelizes nicely, since I do large atomic disk reads of the entire
file into a memory stream, letting the disk do sequential reads for each file.
With 2 worker threads, this works great. Triple the throughput..
But with 4 worker threads Out of Memory exceptions
start popping up. Currently just doing a try/catch/ Sleep/retry on these...
This lets some of the other threads finish thier bigger files, allowing
memory to be released.
This all works to some degree just with degraded performance (idled cores)
when a series of big files are encountered.
So, to the question:
Has anyone seen an implementation of a ForwardOnlyMemoryStream?
This would be the same as a memory stream, except that there would
be a Trim Method. Everything before the current StreamPosition would
be released from memory. I would call this after every 100KB of records
are read maybe.
The benefit would be that as each thread loads a big file, it will release
memory slowly and consistently, instead of one big release when the file
is done. This would allow better scaling without having to idle some cores
waiting for RAM to become available.
Sadly, 64 bit is not common yet..