efficient rpc io using vstr

Michael B Allen mba2000 at ioplex.com
Tue Jan 20 01:14:18 GMT 2004


Martin Pool said:
> Here's an sketch of the kind of packet buffering using vstr that I
> mentioned to tridge yesterday.  More discussion is in the comments.
>
> A sample input file is here
>
>   http://sourcefrog.net/projects/vstr-readpacket/
>
> I haven't benchmarked it other than running it under strace.

I've had discussions with the author of vstr about his library. Personally
I don't like it for a variety of reasons. Mainly IMHO C string
abstractions are unncessary because of the powerful C feature that is
pointer arithmetic. More practically, one problem is that vstr has nothing
to do with strings really. It's an I/O buffering strategy that trys to
hide pointer arithmetic from the user by managing pointers to data that
doesn't change. This might be useful to Samba for packet processing. I
don't really know. But using it for character string manipulation might
give you some problems because a) it is completely oblivious to
internationalization and b) certain manipulation is going to cause
allocation and copying of possibly large numbers of little fragments. Your
talloc code (or suba[1]) would be better for this. My personal preference
has always been to just use "copy as you parse" techniques wherever
reasonable. That can totally eliminate a lot of strlen/strcpy kind of work
which is what vstr is designed to deal with.

Mike

[1] suba the "sub-allocator" written by myself:
http://www.ioplex.com/~miallen/libmba/dl/docs/ref/suba.html



More information about the samba-technical mailing list