Why does a single integer assignment statement consume all of my CPU? -- Raymond Chen

A fresh here's-the-code-spot-the-performance-problem analysis.

Why does a single integer assignment statement consume all of my CPU?

by Raymond Chen

From the article:

Profiling showed that over 80% of the time spent by Calculate­The­Value was inside the Set­Int32 method call, in particular on the line

  *reinterpret_cast<int32_t *>(m_data) = value;

Why does it take so much time to store an integer to memory, dwarfing the actual computation to calculate that integer?

Spoiler hint: [Chaotic neutral]

Stroustrup speaking in India: 'No programming language is perfect' -- Ashwin Khan

stroustrup-pune.PNGCoverage of a stop on Bjarne Stroustrup's January world tour, from our Indian correspondent:

'No programming language is perfect'

By Ashwin Khan

From the article:

Renowned Danish computer scientist Bjarne Stroustrup, inventor of the widely used programming language C++, spoke engagingly about his creation to a packed audience of over 700 people at Dewang Mehta Auditorium, Persistent Systems on Thursday night. The event was attended by mostly IT professionals and students, who flocked to hear Stroustrup speak about how C++ has evolved and the future of programming...

Operator Overloading -- Arne Mertz

Arne Mertz describes in a series of articles the principles of operator overloading.

Operator Overloading

Operator Overloading: Common Practice

by Arne Mertz

From the articles:

Operators can be used to make user defined classes act like known types, e.g. like numbers, pointers and iterators. That way they facilitate the usage of those classes. They can also be used to make your objects do whatever you want them to do, for example build structures that save the operations for later evaluation. The latter is especially useful for building embedded DSLs and gives enough subject matter for a whole series of blog posts. [The first] post will cover the former use of operator overloading, i.e. writing operators that behave like “normal” operators.

... In [the second] post I will go into the details and write a bit about each operator and how a straight forward implementation might look if the operator is meant to work similar to built in operators.

 

The Rule of Zero -- Glennan Carnie

A complementary guideline to help to simplify the application code, without risking resource management issues.

The Rule of Zero

In a previous article – "The Rule of the Big Four (and a half)" we looked at resource management policies in C++.

Resource management is the general term for using the mechanisms in C++ to ensure that resources – files, dynamic memory, sockets, mutexes, etc – have their lifetimes automatically controlled so as to prevent resource leaks, deadlocks, etc. C++ refers to these mechanisms as RAII/RDID ( “Resource Acquisition Is Initialisation / Resource Destruction is Deletion”)

In this article we’ll have a look at a complementary guideline to help simplify your application code, without risking resource management issues – The Rule of Zero.

If you’re not familiar with the concepts of resource management I’d highly recommend having a look at the whitepaper before reading on.

Deleaker For Free For OpenSource Project Owners

[From time to time vendors use Suggest an Article to submit blog suggestions, like this one. We felt this would be of interest to readers. --Ed.]

 

Free License Offer

We've decided to offer Deleaker for free for all who has open source projects and want to fix leaks in the code fast. We just ask to mention Deleaker. That's all.

To get a license please contact us.

What is Deleaker?

Deleaker is a tool for Visual C++ developers to find memory leaks, GDI leaks, COM / OLE leaks, handle leaks and other leak types.

In the past Deleaker was available as extension for Visual Studio 2005, 2008, 2010, 2012 and 2013. Unfortunately it made Deleaker unavailable for those who uses Express Edition as Express Edition doesn't support extensions.

We have just released new build 3.0.27 that includes standalone edition of Deleaker.

How does Deleaker work?

Deleaker is based on hooks. For each allocation and deallocation it saves stack traces and one a user click to Take snapshot it shows all allocations that are not freed yet.

Deleaker is available as Visual Studio extension and as a standalone tool.

Just a few screenshots. Extension mode:

Standalone edition of Deleaker:

C++ in 2015

My yearly overview on the things that might come:

C++ in 2015

by Jens Weller

From the article:

The year is still young, so lets have an outlook about what is going to happen in C++ Land in 2015...

The C++ Memory Model - Valentin Ziegler @ Meeting C++ 2014

A new video from Meeting C++ 2014:

The C++ Memory Model

by Valentin Ziegler

From the talk description:

The C++ memory model defines how multiple threads interact with memory and shared data, enabling developers to reason about concurrent code in a platform independent way. The talk will explain multi-threaded executions and data races in C++...

Reader Q&A: auto and for loop index variables -- Herb Sutter

Discussion on how to use/replace auto for loop index variables.

Reader Q&A: auto and for loop index variables

by Herb Sutter

From the reader's question:

So I’ve been reading all I can about c++11/c++14 and beyond when time permits.  I like auto, I really do, I believe in it.  I have a small problem I’m trying to decide what to do about.  So in old legacy code we have things like this:

for (int i = 0; i < someObject.size(); i++) { … }

New C/C++ compiler for Linux on z Systems -- IBM

ibm.PNGAnother modern C++ compiler released by IBM, based on a modern foundation:

New C/C++ compiler for Linux on z Systems

Today, IBM announced a brand new C/C++ compiler for Linux on z Systems. Built on top of the advanced optimization technology already in use by the Java and Enterprise COBOL compilers, the XL C/C++ for Linux on z Systems compiler generate highly optimized code to significantly improve runtime performance of applications. It leverages the Clang open source infrastructure for a portion of the compiler front end resulting in a high level of source compatibility with GCC and includes partial support of the latest C11 and C++11 language standards. In addition, the XL C/C++ for Linux on z Systems is able to exploit the new z13 hardware announced today through the use of the qarch and qtune suboptions. High performance mathematics libraries, MASS (Mathematical Acceleration Subsystem) and ATLAS (Automatically Tuned Linear Algebra Software) will also be packaged with the compiler and made available for the first time on zLinux.

The XL C/C++ for Linux on z Systems V1.1 runs on RHEL 6, RHEL 7, SLES 11, and SLES 12 and will become generally available on February 16, 2015. For more information on this new compiler, visit the XL C/C++ for Linux on z Systems product page.