Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a cold/dead field and what is a peeling optimization?

In the paper Loop Recognition in C++/Java/Go/Scala (pdf) we find the following quote in the section C++ Tunings:

Structure Peeling. The structure UnionFindNode has 3 cold fields: type_, loop_, and header_. Since nodes are allocated in an array, this is a good candidate for peeling optimization. The three fields can be peeled out into a separate array. Note the header_ field is also dead – but removing it has very little performance impact. The name_ field in the BasicBlock structure is also dead, but it fits well in the padding space so it is not removed.

Can some explain to me what cold/dead fields are, and what a peeling optimization is (I understand what the author did there, but what is the rationale behind it)?

like image 203
Björn Pollex Avatar asked Jul 27 '11 08:07

Björn Pollex


1 Answers

Structure peeling is an optimization where you divide a structure into several ones to improve data locality (in order to reduce cache misses). You separate "hot" data (frequently accessed) from "cold" data (seldomly accessed) into two structures to improve the efficiency of the cache, by maximizing the probability of cache hits.

In the article, the authors decided to move the type_, loop_ and header_ fields away from the more frequently accessed fields.

For more information, you can have a look at this scientific article about structure layout optimization, which contains a description of structure peeling among other techniques: Structure Layout Optimizations in the Open64 Compiler: Design, Implementation and Measurements

If you have access to the ACM digital library, you can also download Practical structure layout optimization and Advice.

like image 157
Luc Touraille Avatar answered Sep 18 '22 20:09

Luc Touraille