Re: String COW?

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Wed, 21 Jan 2009 08:08:23 -0700

On 01/21/2009 05:07 AM, Henrik Nordstrom wrote:
> Still reading the IRC meeting notes regarding String/Buffer, and I
> stubled across COWs.. Had forgot we has such beasts flying around in the
> Sting/Buffer discussion.
>
> in what context do we need COW? We very very rarely modify anything. We
> copy lots of crap around just for the sake of copying, and making
> strings null terminated (either in-place or by copying, doesn't really
> matter).
>
> With String being backed by a refcounted store copying is eleminated.
>
> In the rare cases that the strings really need to be modified then a
> copy in a structured manner is needed. And is imho best done by a
> explicit interface.

I agree that COW may not be needed often in the primary flow of the
current code. If we start optimizing message header construction by
modifying the original header in-place, it may become used on every message.

COW does not cost much performance-wise after you paid for refcounting
and it is a very powerful/convenient tool to have. Moreover, emulating
it safely using some kind of explicit interface probably would not work
well because folks will forget to use it or will use it incorrectly.

Thus, it seems like a good idea to put it in early, when it is easy to
do so.

Cheers,

Alex.
Received on Wed Jan 21 2009 - 15:10:26 MST

This archive was generated by hypermail 2.2.0 : Wed Jan 21 2009 - 12:00:26 MST