Idea to minimize buffer allocations in PhysicalFileProvider
davidfowl opened this issue · 7 comments
davidfowl commented
Credit goes to @stephentoub
Pass the minimum buffer size (1) to the FileStream constructor and have callers use pooled buffers for reading.
pakrym commented
Would it read skipping internal buffer in this case?
davidfowl commented
That's the idea.
pakrym commented
I'll try and profile it tomorrow.
pakrym commented
Would be nice to allow passing 0 to bufferSize
then.
stephentoub commented
While it may be nice aesthetically, it shouldn't really impact anything. The buffer shouldn't be allocated (at least not in corefx), as the buffer is lazily-initialized and will be skipped if the number of bytes to be read is >= bufferSize.
pakrym commented
Yes, I implemented it. Buffer allocations from FileStream
are not a problem anymore.