On this sunday, while playing on improving Npgsql performance and reviewing Ralph Mason's contributed code and Hubert Fongarnand bug report, I did a small modification which increased performance significantly.
Nunit test case which used to run in a little bit more than 5, 6 seconds, turned out to run in about 2.3 seconds!! :)
Also, Prepared statements performance was vastly improved.
The modification? Just changed the following line in NpgsqlClosedState.cs:
context.Stream = stream;to
context.Stream = new BufferedStream(stream);
Yeah, just a buffered stream usage :)
I'm doing some more changes as well as integrating the aforementioned patches and improvements. This modification will be the first to hit cvs today.
Update: Well, the truth is that it wasn't a single line change :( I reviewed the code later and checked that performance improvement was also because of less calls to Stream.Flush() methods. These too much calls were destroying the gain obtained from BufferedStream.