Boost.MultiIndex was launched as part of Boost 1.32 in November 2004. The library is still actively maintained and in use by some notable projects such as BitcoinCore , CERN ATLAS , ClickHouse , Folly and Redpanda , to name a few. Back in 2004, variadic templates and typelists were emulated in C++03 with the help of libraries like Boost.Preprocessor and Boost.MPL . These libraries were ground…
After the publication of the experiments with Boost.Unordered on Fil-C , some readers asked for a comparison of run-time performances between Fil-C and Clang's AddressSanitizer (ASAN). Warning Please do not construe this article as implying that Fil-C and ASAN are competing technologies within the same application space. Whereas ASAN is designed to detect bugs resulting in memory access…
Fil-C is a C and C++ compiler built on top of LLVM that adds run-time memory-safety mechanisms preventing out-of-bounds and use-after-free accesses. This naturally comes at a price in execution time, so I was curious about how much of a penalty that is for a performance-oriented, relatively low-level library like Boost.Unordered . Compiling and testing From the user's perspective, Fil-C is…
Starting in Boost 1.90, Boost.Bloom will provide so-called bulk operations , which, in general, can speed up insertion and lookup by a sizable factor. The key idea behind this optimization is to separate in time the calculation of a position in the Bloom filter's array from its actual access. For instance, if this is the the algorithm for regular insertion into a Bloom filter with k = 1 (all the…
(From a conversation with Vassil Vassilev.) Suppose we want to have a C++ map where the keys are disjoint, integer intervals of the form [ a , b ]: struct interval { int min, max; }; std::map<interval, std::string> m; m[{0, 9}] = "ABC"; m[{10, 19}] = "DEF"; This looks easy enough, we just have to write the proper comparison operator for intervals, right? bool operator<(const interval& x, const…
Goals of standardization Standardizing programming languages WG21 Innovation vs. adoption Pros and cons of standardization An assessment model for library standardization Boost, the standard and beyond Golden era: 1998-2011 Middle-age issues: 2012-2020 Evolution: 2021-2024 and the future Conclusions Goals of standardization Standardization, in a form resembling our contemporary practices, began in…
Suppose we have a std::set<int> and would like to retrieve the elements between values a and b , both inclusive. This task is served by operations std::set::lower_bound and std::set::upper_bound : std::set<int> x=...; // elements in [a,b] auto first = x.lower_bound(a); auto last = x.upper_bound(b); while(first != last) std::cout<< *first++ <<" "; Why do we use lower_bound for the first iterator…
Introduction Prior art Bulk visitation design Performance analysis Conclusions and next steps Introduction boost::concurrent_flat_map and its boost::concurrent_flat_set counterpart are Boost.Unordered's associative containers for high-performance concurrent scenarios. These containers dispense with iterators in favor of a visitation -based interface: boost::concurrent_flat_map< int , int > m; ...…
It is generally known that type qualifiers (such as const and volatile in C++) can be regarded as a form of subtyping : for instance, const T is a supertype of T because the interface (available operations) of T are strictly wider than those of const T . Foster et al. call a qualifier q positive if q T is a supertype of T , and negative it if is the other way around. Without real loss of…
Introduction State of the art Design principles Data structure Algorithms Lookup Insertion Visitation API Benchmarks Conclusions and next steps Introduction Starting in Boost 1.83, Boost.Unordered provides boost::concurrent_flat_map , an associative container suitable for high-load parallel scenarios. boost::concurrent_flat_map leverages much of the work done for boost::unordered_flat_map , but…
Introduction The case for open addressing SIMD-accelerated lookup boost::unordered_flat_map data structure Rehashing Hash post-mixing Statistical properties of boost::unordered_flat_map Benchmarks Running- n plots Aggregate performance Deviations from the standard Conclusions and next steps Introduction Starting in Boost 1.81 (December 2022), Boost.Unordered provides, in addition to its previous…
Suppose our program deals with heavy entities of some type object which are uniquely identified by an integer ID. The following is a possible implementation of a function that controls ID-constrained creation of such objects: object* retrieve_or_create ( int id) { static std::unordered_map< int , std::unique_ptr<object>> m; // see if the object is already in the map auto [it,b] = m. emplace (id,…
Introduction Several Boost authors have embarked on a project to improve the performance of Boost.Unordered 's implementation of std::unordered_map (and multimap , set and multiset variants), and to extend its portfolio of available containers to offer faster, non-standard alternatives based on open addressing. The first goal of the project has been completed in time for Boost 1.80 (due August…
std::unordered_map is a highly configurable class template with five parameters: template< class Key, class Value, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator< std::pair<const Key, Value> > > class unordered_map; Typical usage depends on default values for most of these parameters: using my_map=std::unordered_map<int,std::string>; but things…
There have been some discussions on what the best first guess is for the game Wordle , but none, to the best of my knowledge, has used the following approach. After each guess, the game answers back with a matching result like these: ■■■■■ (all letters wrong), ■ ■■ ■ ■ (two letters right, one mispositioned), ■■■■■ (all letters right). There are 3 5 =243 possible answers. From an…
This summer in Spain has been so particularly hot that people came up with graphical jokes like this: ( Cáceres is my hometown; versions of this picture for many other Spanish populations swarm the net.) Pursuing this idea half-seriously, one can reason that an increase in global temperatures due to climate change might be journalistically equated with the Earth getting closer to the Sun and thus…
(Updated after a suggestion from bluescarni .) I recently had to use C++14's std::is_final but wanted to downgrade to boost::is_final if the former was not available. Trusting __cplusplus implies overlooking the fact that compilers never provide 100% support for any version of the language, and Boost.Config is usually helpful with these matters, but, as of this writing, it does not provide any…
Suppose we have a function accepting a C-style callback function like this: void do_something(void (*callback)()) { ... callback(); } As captureless C++ lambda functions can be cast to regular function pointers, the following works as expected: auto callback=[](){std::cout<<"callback called\n";}; do_something(callback); output: callback called Unfortunately , if our callback code captures some…
Louis Dionne poses the problem of move independence in the context of C++, that is, under which conditions a sequence of operations f(std::move(x)); g(std::move(x)); is sound in the sense that the first does not interfere with the second. We give here a functional definition for this property that can be applied to the case Louis discusses. Let X be some type and functions f : X → T × X and g : X…
We use the data gathered at our hysteresis analysis of Spanish gas prices for 2014 and 2015 to gain further insight on their dynamics. This is a simple breakdown of gas (or gasoil) price: Price = oil cost + other costs + taxes + margin. A barrel of crude oil is refined into several final products totalling approximately the same amount of volume, that is, it takes roughly one liter of crude oil to…
We begin the new year redoing our hysteresis analysis for Spanish gas prices with data from 2015, obtained from the usual sources: Retail gasoline and gasoil prices from the European Commision Oil Bulletin . Brent oil spot prices from the the US Energy Information Administration . Euro to dollar exchange rates from FXHistory . The figure shows the weekly evolution during 2015 of prices of Brent…
Yesterday, CUP political party held a general assembly to determine whether to support or not Artur Mas's candidacy to President of the Catalonian regional government. The final voting round among 3,030 representatives ended up in an exact 1,515/1,515 tie , leaving the question unsolved for the moment being. Such an unexpected result has prompted a flurry of Internet activity about the…
In a previous entry we saw how to decouple the logic of a class from the access to its member data so that the latter can be laid out in a DOD -friendly fashion for faster sequential processing. Instead of having a std::vector of, say, particles, now we can store the different particle members (position, velocity, etc.) in separate containers. This unfortunately results in more cumbersome…
(Many thanks to Manu Sánchez for his help with running tests and analyzing results.) In a past entry , we implemented a little C++ framework that allows us to do DOD while retaining some of the encapsulation benefits and the general look and feel of traditional object-based programming. We complete here the framework by adding a critical piece from the point of view of usability, namely the…
Data-Oriented Design, or DOD for short, seeks to maximize efficiency by laying out data in such a way that their processing is as streamlined as possible. This is often against the usual object-based principles that naturally lead to grouping the information accordingly to the user-domain entities that it models. Consider for instance a game where large quantities of particles are rendered and…