Göran,

On 13 Sep 2011, at 09:38, Göran Krampe wrote:

> Hi!
> 
> On 09/12/2011 12:35 PM, Sven Van Caekenberghe wrote:
>> The problem is that the new SocketStream implementation worked fine for me 
>> during development (on Mac), but later I found out that there are subtle but 
>> critical problems on the other platforms.
> 
> Just a few words about the SocketStream implementation. I wrote the current 
> incarnation of SocketStream (unless it has changed under Pharo - haven't 
> looked) and one important aspect of the rewrite was to make it much faster 
> than the old code written originally by Bolot Kerimbaev back in... ancient 
> times.
> 
> Basically two things make it fast:
>       - As little copying as possible.
>       - Making sure code lands on good primitives.
> 
> An example of the former is the logic involved in dealing with the buffer 
> growing etc.
> 
> An example of the latter is upToAll: that could be written naively and end up 
> using next, next for each byte. Ouch.
> 
> Anyway, there are indeed some methods in SocketStream that "hurts the eyes", 
> like upToAll: but that is mainly because we are lacking a primitive for 
> searching that has a "stopAt" argument. I never got around to extending the 
> one we have with such an argument.
> 
> regards, Göran

I respect the current SocketStream: it is used by all of us everyday and it 
works reliably.
The problem is that its code base has grown in all kinds of directions and in 
complexity.
Today it is pretty hard to understand since it is not clear if all code that is 
there is relevant.
Also, subclassing it to build a secure socket stream is pretty difficult.

The Zodiac streams are an experiment in rewriting [secure] socket stream.

I would be honored if you would take some time to look at the code and give 
some feedback

        http://www.squeaksource.com/Zodiac

From one of my previous mails:

Warning: this is of course not yet code for general consumption, use the source 
and the comments. This is a proof of concept.

This package has no further dependencies and does not add anything to system 
classes, it is thus safe to load.

There are four stream classes, ZdcAbstractSocketStream, ZdcSimpleSocketStream, 
ZdcOptimizedSocketStream and ZdcSocketStream, inheriting from each other, 
adding successively more optimized implementations of the standard Smalltalk 
stream primitives, especially for bulk IO. There is one helper class, 
ZdcIOBuffer to help in managing read and write buffers inside the streams. The 
interface towards Socket is also quite small (i.e. only a very small amount of 
the functionality in Socket is used).

The 48 units tests as well as the functional test (see further) are all green 
on Pharo 1.2.x and 1.3 as well as on Squeak 4.2.

The functional test is the following: Zinc HTTP Components recently got a its 
ZnNetworkingUtils class turned into a socket stream factory. By loading the new 
package Zinc-Zodiac from the ZincHTTPComponents repository, you can ask Zn to 
use the new socket stream implementation, like this:

        ZnNetworkingUtils default: ZnZodiacNetworkingUtils new. 

To reset, just do:

        ZnNetworkingUtils default: nil.

The cool thing is: all of Zn's +170 unit tests, most doing actual HTTP client 
and server interactions (some over the internet) succeed using the new Zodiac 
socket stream implementation.

Regards,

Sven


Reply via email to