Diagnostics

The table below presents all the diagnostics we intend to implement. Each diagnostic has a corresponding compile time switch -D_GLIBCXX_PROFILE_<diagnostic>. Groups of related diagnostics can be turned on with a single switch. For instance, -D_GLIBCXX_PROFILE_LOCALITY is equivalent to -D_GLIBCXX_PROFILE_SOFTWARE_PREFETCH -D_GLIBCXX_PROFILE_RBTREE_LOCALITY.

The benefit, cost, expected frequency and accuracy of each diagnostic was given a grade from 1 to 10, where 10 is highest. A high benefit means that, if the diagnostic is accurate, the expected performance improvement is high. A high cost means that turning this diagnostic on leads to high slowdown. A high frequency means that we expect this to occur relatively often. A high accuracy means that the diagnostic is unlikely to be wrong. These grades are not perfect. They are just meant to guide users with specific needs or time budgets.

Table 19.2. Profile Diagnostics

GroupFlagBenefitCostFreq.Implemented 
CONTAINERS HASHTABLE_TOO_SMALL101 10yes
  HASHTABLE_TOO_LARGE51 10yes
  INEFFICIENT_HASH73 10yes
  VECTOR_TOO_SMALL81 10yes
  VECTOR_TOO_LARGE51 10yes
  VECTOR_TO_HASHTABLE77 10no
  HASHTABLE_TO_VECTOR77 10no
  VECTOR_TO_LIST85 10yes
  LIST_TO_VECTOR105 10no
  ORDERED_TO_UNORDERED105 10only map/unordered_map
ALGORITHMS SORT78 7no
LOCALITY SOFTWARE_PREFETCH88 5no
  RBTREE_LOCALITY48 5no
  FALSE_SHARING810 10no

Switch: _GLIBCXX_PROFILE_CONTAINERS.

Switch: _GLIBCXX_PROFILE_ALGORITHMS.

Switch: _GLIBCXX_PROFILE_LOCALITY.

The diagnostics in this group are not meant to be implemented short term. They require compiler support to know when container elements are written to. Instrumentation can only tell us when elements are referenced.

Switch: _GLIBCXX_PROFILE_MULTITHREADED.

Switch: _GLIBCXX_PROFILE_STATISTICS.

In some cases the cost model may not tell us anything because the costs appear to offset the benefits. Consider the choice between a vector and a list. When there are both inserts and iteration, an automatic advice may not be issued. However, the programmer may still be able to make use of this information in a different way.

This diagnostic will not issue any advice, but it will print statistics for each container construction site. The statistics will contain the cost of each operation actually performed on the container.