Thursday, February 9, 2017

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

"Christopher J. Pisz" <cpisz@austin.rr.com>: Feb 09 02:08PM -0600

Seems to be a pretty standard interview screening test. I Googled it
after the fact and it pops up with a page of hits. Everyone seemed to
pretty much do what I did, yet I have been told mine performs like poop
compared to other candidates. I can't get any feedback on why it might
perform like poop or what could be done better.
 
Can you guys give your suggestions?
http://github.com/ChristopherPisz/Asking-for-Peer-Review/tree/master/Boggle
 
I did a depth first search and compared the path thus far with words in
the dictionary using a Radix Trei. I don't know of any other possible
algorithm to solve the problem, or how I would implement it "better."
 
C++ is getting REALLY performance orientated. I used to get a job within
2 days just by knowing what virtual inheritance is. Now, I don't really
know how to "Get better"
Paavo Helde <myfirstname@osa.pri.ee>: Feb 10 12:06AM +0200

On 9.02.2017 22:08, Christopher J. Pisz wrote:
 
> C++ is getting REALLY performance orientated. I used to get a job within
> 2 days just by knowing what virtual inheritance is. Now, I don't really
> know how to "Get better"
 
 
From a quick glance from your code I would say there is massive
overengineering in the Dictionary area. For finding words matching a
prefix one can just store them in a std::set and use
std::set::lower_bound(), no need to build complex hierarchies of classes.
 
I also see you have used std::upper_bound() on a pair of std::set
iterators, this is probably the most counter-performance thing there.
There is a reason why std::set has lower_bound() and upper_bound() as
member functions.
 
You also need to learn about std::string::compare(), I see things like
that in your code:
 
if ((*itChild)->m_value.substr(0, wordPart.size()) == wordPart) ...
 
Yes, C++ is a lot about performance nowadays, if there is no need for
performance the thing could be often programmed much more easily in some
scripting language.
 
Cheers
Paavo
"Christopher J. Pisz" <cpisz@austin.rr.com>: Feb 09 04:36PM -0600

On 2/9/2017 4:06 PM, Paavo Helde wrote:
> overengineering in the Dictionary area. For finding words matching a
> prefix one can just store them in a std::set and use
> std::set::lower_bound(), no need to build complex hierarchies of classes.
 
 
I used std::lower_bound in my first submission and they said that was
shit, so I tried again with the Radix Trei.
 
Radix Trei is O(k) where k is the length of the word, if I understand
correctly, while lower_bound is O(logn) with n being the number of words
in the dictionary, right?
 
They hinted at the dictionary being some 20MB of words, so I figure the
lookup part is very significant.
 
In my tests, the gains were really minimal though and the code far more
complex, like you say, but I don't have a 20MB dictionary to test with.
 
 
> iterators, this is probably the most counter-performance thing there.
> There is a reason why std::set has lower_bound() and upper_bound() as
> member functions.
 
Hmm, whats the difference between the two?
You're talking about calling
 
std::lower_bound(myset.begin(), myset.end(), value);
vs
myset.lower_bound(value);
 
?
I thought they are equivalent, is that incorrect?
 
 
 
> You also need to learn about std::string::compare(), I see things like
> that in your code:
 
> if ((*itChild)->m_value.substr(0, wordPart.size()) == wordPart) ...
 
I feel dumb. Never used std::string::compare
So the equivalent would be
 
if ( (*itChild)->m_value.compare(0, wordPart.size(), wordPart) == 0) ??
and that would prevent one temporary from the substr return?
 
 
> scripting language.
 
> Cheers
> Paavo
 
How do I prepare myself for the transition of doing 10 years of mostly
back-end business services to doing more "high performance" code?
 
I appeased Flibble by using uint_32 and its kin where size or
portability are an issue.
 
I am doing all I can on HackerRank. Algorithms and Data structures.
 
I am performance testing code I write and alternatives, but of course I
come up with both myself, so I might not have the best alternatives.
 
I've looked up custom memory management and practiced it.
 
I've come to terms with people insisting on using c-style code in some
performance intensive areas, like sprintf vs stream.
 
I've reviewed the complexity of operations on the common data structures
every day this month.
 
I am not sure what else I can do.
I am a 40 year old man about to cry if I don't get a job soon.
 
 
Thanks for your feedback man. I appreciate all you guys on this newsgroup.
Ian Collins <ian-news@hotmail.com>: Feb 09 05:51PM +1300

On 02/ 9/17 09:59 AM, Paavo Helde wrote:
>> cpu3 28215097 729617 22785914 1259180937 2203630 601 598373 0 115891
 
> So for finding out the current load I need to read /proc/stat, wait a
> bit, and read it again? There is nothing like /proc/loadavg per CPU?
 
I have some code for gather and collating stats from /proc if you are
interested.
 
--
Ian
Paavo Helde <myfirstname@osa.pri.ee>: Feb 09 10:53AM +0200

On 9.02.2017 6:51, Ian Collins wrote:
>> bit, and read it again? There is nothing like /proc/loadavg per CPU?
 
> I have some code for gather and collating stats from /proc if you are
> interested.
 
I am not so sure any more if I actually need to use these stats. But if
this does not do any trouble to you, then maybe you could indeed post
the code or download instructions here or to my e-mail.
 
Thanks,
Paavo
"Chris M. Thomasson" <invalid@invalid.invalid>: Feb 09 01:08PM -0800

On 2/8/2017 12:44 AM, Paavo Helde wrote:
> nodes in the computer. Could you suggest a portable (at least
> Windows+Linux) C or C++ library for doing this? My google-fu is somehow
> failing me today...
 
I guess you can give this a try:
 
https://software.intel.com/en-us/intel-vtune-amplifier-xe
 
Also guess you can perhaps pin some threads to the NUMA nodes that can
give some crude timing data. How are you arranging your overall
synchronization scheme? Are you using affinity masks at all, or letting
the OS handling things from that perspective?
"Chris M. Thomasson" <invalid@invalid.invalid>: Feb 09 01:17PM -0800

On 2/8/2017 12:44 AM, Paavo Helde wrote:
> nodes in the computer. Could you suggest a portable (at least
> Windows+Linux) C or C++ library for doing this? My google-fu is somehow
> failing me today...
 
Fwiw, a somewhat related thread:
 
https://groups.google.com/d/topic/comp.programming.threads/XU6BtGNSkF0/discussion
 
(read all if interested, it involves using timing for hazard ptr impl)
 
This was back when comp.programming.threads was really great!
Paavo Helde <myfirstname@osa.pri.ee>: Feb 09 11:43PM +0200

On 9.02.2017 23:08, Chris M. Thomasson wrote:
>> failing me today...
 
> I guess you can give this a try:
 
> https://software.intel.com/en-us/intel-vtune-amplifier-xe
 
AFAIK vtune is an application, not a library. When I said "I need to
find out" I actually meant "my library code needs to find out, when
running as a part of a some unknown application on some unknown hardware.
 
> give some crude timing data. How are you arranging your overall
> synchronization scheme? Are you using affinity masks at all, or letting
> the OS handling things from that perspective?
 
Yes I am attempting to bind a parallel thread pool in my program to a
single NUMA node (because profiling shows there is no point to let it
spread across nodes, it would be just wasting computer resources). What
I need is to figure out which NUMA node to bind to.
 
Cheers
Paavo
woodbrian77@gmail.com: Feb 09 11:20AM -0800

> > libraries so I checked how much difference it would make size-wise if
> > that function was in a .cc file. Doing so reduced the size of the
> > application's text segment by 128 bytes.
 
 
Since writing this I realized I could achieve the same effect
by not emitting the "inline" keyword in the generated header.
So I added support for an @no_inline option to my code
generator. A few days ago I thought I was going to have to
leave those 128 bytes on the table, as a tradeoff for the
convenience of having a header-only library. This allows me
to snag those bytes and keep the convenience. I only need
to include the generated header in one translation unit so
can get away with removing that inline.
 
https://github.com/Ebenezer-group/onwards/commit/27951bcf9594b6cf9e0a5b514a2fdced17a5f6b1
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
woodbrian77@gmail.com: Feb 09 08:37AM -0800

On Monday, February 6, 2017 at 2:25:17 AM UTC-6, Öö Tiib wrote:
> My impression of 'boost::any' however is negative from
> every side: slow, inconvenient, fragments memory and
> produces cryptic diagnostics.
 
We want to be rewarded for time spent reading some code: "any"
doesn't go very far in terms of conveying useful information
to readers. I wish it weren't being added to the standard.
 
 
Brian
Ebenezer Enterprises - "The robb'd that smiles steals something
from the thief." William Shakespeare
 
http://webEbenezer.net
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: