Sunday, August 5, 2018

Digest for comp.lang.c++@googlegroups.com - 5 updates in 4 topics

Tim Rentsch <txr@alumni.caltech.edu>: Aug 05 07:45AM -0700

>> disadvantageous properties: it will not reclaim cyclic structures
>> unless they explicitly have the cycles removed;
 
> Using std::weak_ptr might provide some mitigation here.
 
Sure. But that starts to move into the domain of doing manual
management. One needs to think about where to use the weak
pointers: not enough, and cycles don't get reclaimed; too many,
and the data structure falls apart too early. That doesn't mean
reference counting is hopeless -- any non-trivial application does
some level of manual management, and even full-scale mark/sweep
environments need weak pointers in some circumstances. The
important thing is that making sure everything gets reclaimed
incurs a mental cost, and that cost is higher for reference
counting than it is for mark/sweep-style collectors.
 
> heavyweight because the reference-count update is required to be
> multithread-safe. A single-thread only smartpointer is much faster in
> multithreaded programs, but its usage obviously requires more care.
 
(Disclaimer: I'm not a unique_ptr expert. I did look into the
issues here, and believe my comments below are correct, but I very
well may have missed or misunderstood something. All feedback
welcome.)
 
First, my comment was about reference counting, and unique_ptr is
not reference counting. Or it may be thought of as 1-bit RC -- it
either has a non-null pointer or it doesn't (and the "count" is in
the unique_pointer itself, not in shared per-object memory). In
any case it is definitely less automatic than full RC (which I take
as being equivalent to shared_ptr, with a similar disclaimer). As
such it requires more mental effort than using shared_ptr or some
other more complete RC scheme.
 
Second, regarding resource use. The idea that unique_ptr has no
space or time overhead is, I believe, incorrect. In particular,
when updating a unique_ptr from a different unique_ptr (temporary),
there is a space cost in the form of code space needed for a value
check, and a time cost in checking the value to see if a destructor
needs to be called. Those may not be large costs, but they are not
zero. Compare to a mark/sweep-style environment, where all that
needs to happen is copying the pointer.
 
Third, besides needing more manual management, using unique_ptrs
carries an additional mental cost in having to understand the more
elaborate language semantics that they rely on. In particular,
unique_ptr has move semantics but not copy semantics. The kinds of
code patterns used for "normal" objects (ie, that do have copy
semantics) in many cases simply don't apply to unique_ptrs. To use
unique_ptrs requires a new kind of thinking, which means more mental
cost. I'm not saying these things can't be learned -- obviously
they can be. But there is an initial cost in learning, and more
importantly an ongoing cost in using (cost here meaning mental
effort) things like unique_ptr that don't use the usual semantic
constructs. If that use could be tucked away underneath a layer of
abstraction that would be one thing, but with unique_ptr it's right
there in your face and there's no getting around having to deal with
it. Is that a good tradeoff to make? I expect in some cases it is.
I believe though that in many cases a different tradeoff would be
better.
 
>> lead to hard-to-understand behavior in the presence of exception
>> processing.
 
> Not sure what you want to say here? [...]
 
Invariants maintained locally and incrementally are often harder
to get right and harder to understand than invariants maintained
centrally.
 
>> big increase in productivity, which has been measured as a
>> factor somewhere between 1.5 and 2.
 
> Compared to what?
 
Compared to doing all memory management manually.
 
> To the proper C++ code using std::vector,
> std::string, std::make_unique, std::make_shared, or to the C or
> C-style C++ code calling malloc/free or new/delete manually?
 
Even just using unique_ptr and shared_ptr, C++ provides a form of
reference counting, which is more automatic management than having
to manage all memory (de-)allocation manually. I don't know of any
studies that compare the productivity results of using reference
counting versus a more centralized form of garbage collection such
as mark/sweep. Based on personal experience I expect that some
level of increased productivity would be found, but it would be
nice to get some more objective results on that.
 
> I'm sure GC suits fine some programs.
 
Yes, and the question is which programs (and which classes of
programs). I would never claim that any approach is right for all
applications. But I think many people, or maybe even most people,
form opinions about that based on pre-conceptions that turn out
not to be right if examined more closely, so I like to encourage
people to look at things from different points of view, and see
if their perceptions might change on further investigations.
Juha Nieminen <nospam@thanks.invalid>: Aug 05 07:00AM

>>> #include <ostream>
 
>> Rather redundant, don't you think?
 
> With C++11 and later, yes.
 
Given that the code is C++11, it is thus literally redundant.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Aug 05 10:45AM +0200

On 05.08.2018 09:00, Juha Nieminen wrote:
 
>>> Rather redundant, don't you think?
 
>> With C++11 and later, yes.
 
> Given that the code is C++11, it is thus literally redundant.
 
That's a good point.
 
I was thinking mainly that Stefan's conventions for his course materials
possibly predate C++11.
 
 
Cheers!,
 
- Alf
Sky89 <Sky89@sky68.com>: Aug 05 01:35AM -0400

Hello....
 
 
What is computing for me ?
 
It is first finding an efficient "abstraction" and being able
to hide or reduce "complexity", and also Loose coupling is also like
hiding or reducing complexity, i am always doing it on my software
projects, and to be able to do it more efficiently you have to be more
smart, also i am always looking to reduce efficiently the serial part of
the parallel program, i am calculating it by CPU cycles and this part of
my work is like "assembler", and this to be able to "predict" more
correctly scalability, look for example at my Parallel Compression
Library or my Parallel archiver here:
 
https://sites.google.com/site/scalable68/parallel-compression-library
 
https://sites.google.com/site/scalable68/parallel-archiver
 
Notice that it says:
 
- It's NUMA-aware and NUMA efficient on windows (it parallelizes the
memory reads and writes on NUMA nodes)
 
and
 
- It minimizes efficiently the contention so that it scales well
 
and
 
Now it uses only two threads that do the IO (and they are not
contending) so that it reduces at best the contention, so that it scales
well.
 
and
 
- Now it supports processor groups on windows, so that it can use more
than 64 logical processors and it scales well.
 
And notice that it says the following:
 
I have done a quick calculation of the scalability prediction for my
Parallel Compression Library, and i think it's good: it can scale beyond
100X on NUMA systems.
 
The Dynamic Link Libraries for Windows and Dynamic shared libraries for
Linux of the compression and decompression algorithms of my Parallel
Compression Library and for my Parallel archiver were compiled from C
with the optimization level 2 enabled, so they are very fast.
 
So as you noticed i am making my Parallel Compression Library and
Parallel archiver efficient.
 
Also computing for me is also finding a good and more efficient way to
ensure reliability and stability, and this part of my work has been
enhanced more by my "experience" in computing and by implementing more
serious softwares.
 
Also computing for me is also making my software portable, this why i
said before the following:
 
About portability of my software projects
 
I have thought more, and as you have noticed i have written Intel
assembler routines for 32 bit and 64 bit for atomically incrementing and
and for atomically CompareExchange etc. so now they are working with x86
AMD and Intel processors for 32 bit and 64 bit, but i will soon make my
Delphi and FreePascal and C++ libraries portable to the other CPUs like
ARM(for Android) etc. for that i will use the following Delphi methods
for Delphi:
 
http://docwiki.embarcadero.com/Libraries/XE8/en/System.SyncObjs.TInterlocked.CompareExchange
 
and
 
http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.SyncObjs.TInterlocked.Exchange
 
 
And I will use the same functions that you find inside FreePascal, here
they are:
 
https://www.freepascal.org/docs-html/rtl/system/interlockedexchange64.html
 
and
https://www.freepascal.org/docs-html/rtl/system/interlockedexchange.html
 
and
 
https://www.freepascal.org/docs-html/rtl/system/interlockedcompareexchange.html
 
and
 
https://www.freepascal.org/docs-html/rtl/system/interlockedcompareexchange64.html
 
 
I will use them inside my scalable lock that is called scalable MLock
that i have "invented", so that it will be portable, here it is:
 
https://sites.google.com/site/scalable68/scalable-mlock
 
 
And when my scalable MLock will become portable on Delphi and FreePascal
i will port with it all my other libraries that uses atomically
increment and decrement etc., so my libraries will become portable to
the other CPUs like ARM for Android etc., so i think you will be happy
with my work.
 
Also what is computing for me ?
 
Read the rest to understand better my work:
 
What about the today computing ?
 
You have to know me more..
 
I am not thinking becoming an expert of "coding"..
 
I am not like that..
 
Because I am an "inventor", and i have invented many scalable algorithms
and there implementations to do better HPC(high performance computing),
i am thinking NUMA systems, and i am thinking "scalability" on manycores
and multicores and on NUMA systems etc. this is my way of "thinking",
and as a proof look at my new scalable reference counting with efficient
support for weak references, here it is:
 
https://sites.google.com/site/scalable68/scalable-reference-counting-with-efficient-support-for-weak-references
 
As you have noticed it is "fully" scalable reference counting, so this
is HPC(high performance computing) , and i have implemented this
scalable algorithm that i have "invented" in Delphi and on the Delphi
mode of FreePascal , so that to make Delphi and FreePascal "much"
better, and notice with me that you will not find it on C++ or Rust.
This is my way of thinking , i am "inventing" scalable algorithms and
there implementations.
 
And i said the following:
 
"I think that this Parallel ForEach and ParallelFor are like futulities,
because they don't bring "enough" high level abstraction to consider
them interesting, because i think my Threadpool with priorities that
scales very well is capable of easily emulating Parallel ForEach with
"priorities" and ParallelFor with "priorities" that scale very well, so
no need to implement Parallel ForEach or Parallel For."
 
But to be "nicer", i think i will soon implement both Parallel ForEach
with "priorities" that scales very well and ParallelFor with
"priorities" that scales very well using my Threadpool with priorities
that scales very well, and they will be integrated as methods with my
Threadpool with priorities that scales very well, so that you will be happy.
 
So i will ask you ? where will you find my Threadpool with priorities
that scales very well? and where you will find my Parallel ForEach and
Parallel For with priorities that scales very well ?
 
You will not find them on C++ and you will not find them on Rust,
because i have "invented" them, because i am an "inventor", and this is
my way of thinking.
 
Here is my powerful Threadpool with priorities that scales very well,
read about it and download it from here:
 
https://sites.google.com/site/scalable68/an-efficient-threadpool-engine-with-priorities-that-scales-very-well
 
It is a very powerful Threadpool, because:
 
More precision about my efficient Threadpool that scales very well, my
Threadpool is much more scalable than the one of Microsoft, in the
workers side i am using scalable counting networks to distribute on the
many queues or stacks, so it is scalable on the workers side, on the
consumers side i am also using lock striping to be able to scale very
well, so it is scalable on those parts, on the other part that is work
stealing, i am using scalable counting networks, so globally it scales
very well, and since work stealing is "rare" so i think that my
efficient Threadpool that scales very well is really powerful, and it is
much more optimized and the scalable counting networks eliminate false
sharing, and it works with Windows and Linux.
Read the rest:
 
Read the rest:
 
You have to understand my work..
 
I have invented many scalable algorithms and there implementations, here
is some of them that i have "invented":
 
1- Scalable Threadpools that are powerful
 
2- Scalable RWLocks of different sorts.
 
3- Scalable reference counting with efficient support for weak references
 
4- Scalable FIFO queues that are node-based and array-based.
 
5- My Scalable Varfiler
 
6- Scalable Parallel implementation of Conjugate Gradient Dense Linear
System Solver library that is NUMA-aware and cache-aware, and also a
Scalable Parallel implementation of Conjugate Gradient Sparse Linear
System Solver library that is cache-aware.
 
7- Scalable MLock that is a scalable Lock.
 
8- Scalable SeqlockX
 
 
And there is also "many" other scalable algorithms that i have "invented".
 
You can find some of my scalable algorithms and there implementations in
Delphi and FreePascal and C++ on my website here:
 
https://sites.google.com/site/scalable68/
 
What i am doing by "inventing" many scalable algorithms and there
implementations, is wanting to make "Delphi" much better and making
FreePascal on the "Delphi" mode much better, my scalable algorithms
and there implementations are like HPC(high performance computing,
and as you have noticed i said also:
 
You will ask why have i invented many scalable algorithms and
there implementations? because also my work will permit us also to
"revolutionise" science and technology because it is HPC(high
performance computing), this is why i will also sell some of my scalable
algorithms and there implementations to companies such as Google or
Microsoft or Embarcadero.
 
Also HPC has revolutionised the way science is performed. Supercomputing
is needed for processing sophisticated computational models able to
simulate the cellular structure and functionalities of the brain. This
should enable us to better understand how our brain works and how we can
cope with diseases such as those linked to ageing and to understand more
about HPC, read more here:
 
https://ec.europa.eu/digital-single-market/en/blog/why-do-supercomputers-matter-your-everyday-life
 
So i will "sell" some of my scalable algorithms and there
implementations to Google or to Microsoft or to Embarcadero.
 
I will also enhance my Parallel archiver and my Parallel compression
Library that are powerful and that work with both C++Builder and Delphi
and to perhaps sell them to Embarcadero that sells Delphi and C++Builder.
 
Also I will implement soon a "scalable" Parallel For and a Parallel
ForEach..
 
This why i said before that:
 
"I think that this Parallel ForEach and ParallelFor are like futulities,
because they don't bring "enough" high level abstraction to consider
them interesting, because i think my Threadpool with priorities that
scales very well is capable of easily emulating Parallel ForEach with
"priorities" and ParallelFor with "priorities" that scale very well, so
no need to implement Parallel ForEach or Parallel For."
 
But to be "nicer", i think i will soon implement both Parallel ForEach
with "priorities" that scales very well and ParallelFor with
"priorities" that scales very well using my Threadpool with priorities
that scales very well, and they will be integrated as methods with my
Threadpool with priorities that scales very well, so that you will be happy.
 
And my next step soon is also to make my Delphi and FreePascal and C++
Libraries portable to other CPUs like ARM etc. because currently they
work on x86 AMD and Intel CPUs.
 
And my next step soon is also to make my "scalable" RWLocks NUMA-aware
and efficient on NUMA.
 
This is was some parts of my everyday computing..
 
Thank you,
Amine Moulay Ramdane.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Aug 05 12:33AM +0100

On 05/08/2018 03:50, Sky89 wrote:
> Hello....
 
> I correct some typos because i write fast, read again..
 
Fuck off you egregious fuckwit of a cunt. AND. TAKE. YOUR. MEDICATION.
 
/Flibble
 
--
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
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: