|
Boost : |
Subject: Re: [boost] [xint] Third release is ready, requesting preliminary review
From: Chad Nelson (chad.thecomfychair_at_[hidden])
Date: 2010-05-02 17:02:01
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 05/02/2010 04:19 PM, Jeffrey Lee Hellrung, Jr. wrote:
>>> Regarding COW specifically: I'm guessing COW will be a tough sell,
>>
>> I keep hearing that, but why? It's an internal detail, one that provides
>> (or at least seems to) a very noticeable speed boost under some
>> circumstances, and is disabled when it can't be safely used. Why would
>> anyone, other than developers doing work on the library (i.e. me), care
>> one way or another that the library uses it?
>
> Because COW is not thread-safe ;) And I'm very curious how this speed
> "boost" (pun intended?) has come about.
I've just posted the results of my testing. As to *why* it's that much
faster, I can only provide educated guesses.
> As Pavel has pointed out, yes, if you make 10 unmodified copies of a COW
> object, it's much faster than 10 unmodified copies of a non-COW object.
> But if I make 10 reference-to-consts of the same object, that's *even
> faster*. Can you give a "real" example where you'd actually *want* to
> produce an unmodified copy of an object, rather than just creating a
> reference-to-const? And doesn't the reference-to-const make your
> intentions ("Dude, I'm not modifying this thing!") that much clearer?
If something's not going to be modified, you might as well make it a
constant reference. I assume the savings come from somewhere else, since
I already use constant references wherever I can get away with it.
> The only example I can think of where COW might come in handy is if you
> do something like
>
> cow* p_x1 = new cow();
> cow* p_x2 = new cow(*p_x1); // no deep copy / shared ownership
> // ... [A] Read from *p_x1, maybe? ...
> delete p_x1; // *p_x2 now has exclusive ownership
If I read your example correctly, then that's about what I was thinking
of: algorithms that have to start with a copy of one or more of the
passed-in parameters, but then need to modify it/them. The division
algorithm requires this, just as one example off the top of my head.
> So, bottom line: Give me a real example of an algorithm where COW
> gives superior performance to move semantics, and I'll buy into the
> COW implementation.
I'll give you one better: the actual timings, which you can reproduce
yourself if you doubt their accuracy. :-) Just let me know if you want
the code I used to come up with them... the rules I read say that I'm
not supposed to post any files to this list, so if you want them, I'll
need to upload the changes somewhere.
- --
Chad Nelson
Oak Circle Software, Inc.
*
*
*
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkvd6EkACgkQp9x9jeZ9/wTurgCg5H8jKM5lMR2QQZuM6Vwv9+/K
skcAn0GPPpV8fT7mqHYjv9ckiZ4QJUUm
=JF6s
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk