New custom stream classes replacing BufferedStream and MemoryStream

Hi all,

Per discussion with @roji, I implemented some Stream classes to replace BufferedStream and MemoryStream, and got them working in Npgsql.

This is really preliminary work, and just the start of a much bigger project that I don't have time to finish, but i think it provides part of the basis needed for Npgsql to really take control of its buffer management.

i did not implement a buffer pool, which may prove to be another important aspect of this project, but a buffer pool is really quite trivial to write, and adapting NpgsqlMemoryStream to it would also be trivial.

The hard, tedious work ahead will lie in refactoring Npgsql to extend and use these new streams to eliminate a lot more allocations and copy operations, partly by taking advantage of the fact that we can have full access to their buffers.

-Glen

Typo :)  I'll fix it.

I won't be of any use on this until the weekend, but I have a couple
additional ideas to try before it gets merged.

-Glen

On Thu, Oct 23, 2014 at 3:41 AM, Frans Bouma <notifications@github.com>
wrote:

> In Npgsql/NpgsqlBufferedStream.cs:
>
> > @@ -0,0 +1,371 @@
> > +﻿using System;
> > +using System.IO;
> > +using System.Text;
> > +
> > +namespace Npgsql
> > +{
> > +    internal class NpgsqlBufferedStream : NpgsqlStream
> > +    {
> > +        public bool ownStream;
>
> a public field?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/npgsql/npgsql/pull/388/files#r19269778>.
>