performance

Three reasons to pass std::string_view by value--Arthur O’Dwyer

You should.

Three reasons to pass std::string_view by value

by Arthur O’Dwyer

From the article:

It is idiomatic to pass std::string_view by value. Let’s see why.

First, a little background recap. In C++, everything defaults to pass-by-value; when you say Widget w you actually get a whole new Widget object. But copying big things can be expensive. So we introduce “pass-by-const-reference” as an optimization of “pass-by-value,” and we tell people to pass big and/or expensive things like std::string by const reference instead of by value.

But for small cheap things — int, char*, std::pair<int, int>, std::span<Widget> — we continue to prefer the sensible default behavior of pass-by-value.

Pass-by-value has at least three performance benefits over pass-by-(const)-reference. I’ll illustrate all three of them via string_view...

C++ String Benchmark -- Giovanni Dicanio

This small article compares different string implementations on the Windows platform.

C++ String Benchmark: STL vs. ATL vs. Custom Pool Allocator

by Giovanni Dicanio

From the article:

I was curious to compare the performance of the STL string implementation versus ATL CString, using Visual Studio 2019, so I wrote some simple C++ benchmark code for this purpose. I also added into the mix a custom string pool allocator.

 

HPX V1.7.1 released -- STE||AR Group

The STE||AR Group has released V1.7.1 of HPX -- A C++ Standard library for parallelism and concurrency.

HPX V1.7.1 Released

The newest version of HPX (V1.7.1) is now available for download! This release fixes minor problems found after the version 1.7.0. It fixes a bug in the internals of actions, adds a version check to the new Asio dependency, and slightly improves the performance of spinlocks among other minor changes. Importantly, the experimental hpx::execution::simdpar execution policy introduced in 1.7.0 was renamed to hpx::execution::par_simd for consistency with the standard parallel execution policies. While this is a breaking change in a patch release, we felt it was important to make this adaptation as soon as possible. The full list of improvements, fixes, and breaking changes can be found in the release notes.

    HPX is a general purpose parallel C++ runtime system for applications of any scale. It implements all of the related facilities as defined by the C++ Standard. As of this writing, HPX provides one of the only widely available open-source implementation of the new C++17 parallel algorithms. Additionally, HPX implements functionalities proposed as part of the ongoing C++ standardization process, such as large parts of the features related parallelism and concurrency as specified by the upcoming C++20 Standard, the C++ Concurrency TS, Parallelism TS V2, data-parallel algorithms, executors, senders/receivers and many more. It also extends the existing C++ Standard APIs to the distributed case (e.g. compute clusters) and for heterogeneous systems (e.g. GPUs).

    HPX seamlessly enables a new Asynchronous C++ Standard Programming Model that tends to improve the parallel efficiency of our applications and helps reducing complexities usually associated with parallelism and concurrency.

 

How to Parallelise CSV Reader - C++17 in Practice--Bartlomiej Filipek

Would do it the same way?

How to Parallelise CSV Reader - C++17 in Practice

by Bartlomiej Filipek

Friom the article:

At C++Stories (and in my C++17 book) you can find several articles on Parallel Algorithms introduced in C++17. The examples included in those posts were usually relatively straightforward. How about writing something larger?

In this text, you’ll see how to build a tool that works on CSV files, parses lines into sales records and then performs calculations on the data.

You’ll see how easy it is to add parallel execution to selected algorithms and have a performance improvement across the whole application (for example 4.5x on 6 cores, including file loading). In the end, we’ll discuss problems that we found along the way and possible future enhancements.

Here’s the plan:

  • How to build an application that loads CSV files
  • How to efficiently use parallel algorithms
  • How to use std::filesystem library to gather required files
  • How to use other C++17 library features like std::optional, conversion routines - std::from_chars and string_view
  • Where to add [[nodiscard]] and improve code readability

Let’s go...

Using C++ Modules in MSVC from the Command Line Part 1--Cameron DaCamara

Time to get familiar!

Using C++ Modules in MSVC from the Command Line Part 1

by Cameron DaCamara

From the article:

In this three-part series we will explore how to build modules and header units from the command line as well as how to use/reference them.

The goal of this post is to serve as a brief tour of compiling and using primary module interfaces from the command line and the options we use...

HPX V1.7.0 released -- STE||AR Group

The STE||AR Group has released V1.7.0 of HPX -- A C++ Standard library for parallelism and concurrency.

HPX V1.7.0 Released

The newest version of HPX (V1.7.0) is now available for download! This release continues the focus on C++20 conformance with multiple new algorithms adapted to be C++20 conformant and becoming customization point objects (CPOs). We’ve also added experimental support for using GCC’s SIMD data types with our parallel algorithms. Finally, we've implemented a large subset of sender/receiver functionality based on current proposals (mainly P0443, P1897, and P2300). HPX futures fulfill the sender concept, and senders can explicitly be turned into futures, which means that codebases can gradually adopt senders where appropriate. The full list of improvements, fixes, and breaking changes can be found in the release notes.

    HPX is a general purpose parallel C++ runtime system for applications of any scale. It implements all of the related facilities as defined by the C++ Standard. As of this writing, HPX provides one of the only widely available open-source implementation of the new C++17 parallel algorithms. Additionally, HPX implements functionalities proposed as part of the ongoing C++ standardization process, such as large parts of the features related parallelism and concurrency as specified by the upcoming C++20 Standard, the C++ Concurrency TS, Parallelism TS V2, data-parallel algorithms, executors, senders/receivers and many more. It also extends the existing C++ Standard APIs to the distributed case (e.g. compute clusters) and for heterogeneous systems (e.g. GPUs).

    HPX seamlessly enables a new Asynchronous C++ Standard Programming Model that tends to improve the parallel efficiency of our applications and helps reducing complexities usually associated with parallelism and concurrency.

 

CppCon 2020 Get Off My Thread: Techniques for Moving Work to Background Threads--Anthony Williams

Registration is now open for CppCon 2021, which starts on October 24 and will be held both in person and online. To whet your appetite for this year’s conference, we’re posting videos of some of the top-rated talks from our most recent in-person conference in 2019 and our online conference in 2020. Here’s another CppCon talk video we hope you will enjoy – and why not register today for CppCon 2021 to attend in person, online, or both!

Get Off My Thread: Techniques for Moving Work to Background Threads

by Anthony Williams

Summary of the talk:

If you're writing a GUI application and you want the interface to feel "responsive" to the user then you need the code that response to UI events to be short and fast. Similarly, if you are handling network I/O you may not want the processing of one request to prevent the system receiving further input.

If the work to be done in response to an event is complex and time consuming then you can maintain the "responsiveness" of the system by passing the work off to a background thread.

This talk will look at the ways of doing this, including managing ongoing work, providing progress updates, and cancelling work if it is no longer needed.