Tuesday, December 6, 2022

Digest for comp.lang.c++@googlegroups.com - 8 updates in 2 topics

Juha Nieminen <nospam@thanks.invalid>: Dec 06 11:36AM

> were 591848 increments and decrements, from which 1526 came from the
> problematic (parallelized) part. It looks like a pessimization to slow
> down 99.75% of accesses when only 0.25% would actually benefit from this.
 
There's place for micro-optimization and there's place to do the
Right Thing (TM) instead.
 
In the vast, vast majority of situations micro-optimization will have
little to no effect on the program. It's only when you have number
crunching code that does something billions of times per second that
micro-optimization may start having some discernible effect. Those
situations tend to be very rare and far-in-between. And when you do
have such situations you can make faster versions of things for that
alone.
 
Micro-optimization is extra useless if it's surrounded by, and thus
swamped by code that's a lot slower than it. Even when micro-optimizing
you should start with the worst offenders, not the smallest things.
 
(By "micro-optimization" I'm referring to things that do not change
the computational complexity of something and only makes that something
some clock cycles faster.)
 
So unless your smart pointer is being copied and assigned around
millions of times per second in tight number-crunching loops, you can
safely ignore any lost clock cycles by making the reference counter
thread-safe.
 
(If you actually need to copy and assign smart pointers around
millions of times per second in a tight number-crunching inner
loop, perhaps create a specialized version of the pointer for
that particular purpose...)
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 06 12:26PM -0800

On 12/6/2022 3:36 AM, Juha Nieminen wrote:
>> were 591848 increments and decrements, from which 1526 came from the
>> problematic (parallelized) part. It looks like a pessimization to slow
>> down 99.75% of accesses when only 0.25% would actually benefit from this.
[...]
> millions of times per second in tight number-crunching loops, you can
> safely ignore any lost clock cycles by making the reference counter
> thread-safe.
[...]
A thread-safe reference counted pointer can heavily damage performance
in certain usage scenarios. Blasting the system with memory barriers and
atomic RMW ops all over the place. Now, there is a work around called
proxy reference counting. Are you familiar with it?
scott@slp53.sl.home (Scott Lurndal): Dec 06 08:39PM

>in certain usage scenarios. Blasting the system with memory barriers and
>atomic RMW ops all over the place. Now, there is a work around called
>proxy reference counting. Are you familiar with it?
 
The fact that smart pointers do allocation/deallocation has made
them useless for high-performance threaded code, IMO.
Paavo Helde <eesnimi@osa.pri.ee>: Dec 06 11:53PM +0200

06.12.2022 22:39 Scott Lurndal kirjutas:
 
 
> The fact that smart pointers do allocation/deallocation has made
> them useless for high-performance threaded code, IMO.
 
You have got it backwards. Smartpointers are taken into use for coping
with the fact that objects need to by dynamically allocated and
deallocated, by the program logic.
 
And this allocation/deallocation would happen relatively rarely. If the
object lifetimes were short, then typically they could be controlled
much better, and there would be no need for refcounted smartpointers, or
maybe even no need for dynamic allocation of objects in the first place.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 06 01:59PM -0800

On 12/6/2022 1:53 PM, Paavo Helde wrote:
> object lifetimes were short, then typically they could be controlled
> much better, and there would be no need for refcounted smartpointers, or
> maybe even no need for dynamic allocation of objects in the first place.
 
Imvvho, a smart pointer should not need to allocate anything under the
covers. Also, are you familiar with proxy reference counting? It has the
ability to amortize a single reference over n objects.
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Dec 06 02:01PM -0800

On 12/6/2022 1:53 PM, Paavo Helde wrote:
> object lifetimes were short, then typically they could be controlled
> much better, and there would be no need for refcounted smartpointers, or
> maybe even no need for dynamic allocation of objects in the first place.
 
Fwiw, RCU is a form of proxy collection. Fwiw, I wrote an experimental
one using pure C++.
 
https://pastebin.com/raw/f71480694
(goes to pure text page, no ads and shit like that...)
scott@slp53.sl.home (Scott Lurndal): Dec 06 10:04PM

>> with the fact that objects need to by dynamically allocated and
>> deallocated, by the program logic.
 
>> And this allocation/deallocation would happen relatively rarely.
 
Assumption not in evidence. I've personnally had to rip smart pointers
out of code because the allocation/deallocation happened very
frequently. One if the applications was simulating a processor pipeline,
another was handling network packets both were written by well-educated
people familiar with C++.
 
Granted, one can specify a more efficient allocator, but
 
1) most C++ programmers don't bother or don't know how
2) Even then there is unnecessary overhead unless the allocator is pool based.
 
KISS applies, always.
"Öö Tiib" <ootiib@hot.ee>: Dec 06 01:03AM -0800

On Monday, 5 December 2022 at 21:43:08 UTC+2, Tim Rentsch wrote:
> just like other kinds of formal verification. It can be more
> work to take into account the range of variation allowed by
> platform variability, but the principles involved are the same.
 
Formal proof of complex system is usually impossible as general
solution is missing even to simple system of three point
masses (three body problem). All platforms are way more complex
than that ... yet made by fallible entities under time-to-market
pressure.
 
 
> > Sure, but only slightly hyperbolic.
 
> On the contrary, more hyperbolic than most. That is the meaning of
> the sentence "a hyperbolic statement if ever there was one."
 
That hyperbole seems to be in our laws. All jurisdictions that I know
of address copyrights of software as those of works of literature.
So software that has not been tested to be useful for something
is on general case just a work of literature written by author of it.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: