Per Hedbor wrote:
Generally speaking, buffers help enormously when reading and parsing from bytestreams into pike, but they do not help all that much when writing to bytestreams. The writev() system call handles the fragmented writes quite nicely (see the pgsql driver) and more efficient than an IOBuffer which would copy the data at least once.
That is only true if you do not include the overhead you get from making the strings. It is also only even close to true if you can always write the whole buffer.
The very common case where you have nonblocking output means you always have to chop off data from the strings, if you have them, and keep track of the array members when you use writev.
Ok, valid points. Both methods have their merits, I guess, depending on the data at hand.
Things like subbuffers is unfortunately actually impossible when using a stringbuilder.
Well, it's not, really. Unless I made some rather striking mistakes.
How do you add the trailing 0, and how do you avoid the fact that the string_builder_x functions can at any time reallocate the 's' member to point to another memory location, making the sub-object totally invalid, and how do you avoid the fact that the str member is actually _part of_ the struct pike-string structure, so you at least temporarily have to overwrite the data in the main buffer?
I guess answering these questions is best done by showing the code (it'll become a long story otherwise). I'll run what I have through the checks today, and check it in. It tracked your changes up till halfway last week, I think, so there still is a little to be done. Incidentally the bugs you fixed in the past few days I simply didn't copy in my implementation in the first place ;-).
perf( String.Buffer() );
Result 2: 325250971 Compilation: 624ns, Execution: 144.86s
Erm, how do you get this nice looking timings? Do I have to turn on a profiling flag on Hilfe somewhere?
set format bench
(did you note the factor of 1k difference in speed in the test?
Yes, I noticed, but that difference was already gone more than a week ago in my local version.