Development/Pahole: Difference between revisions
No edit summary |
(Update part 1) |
||
Line 1: | Line 1: | ||
{{Softwarepage|devel/pahole}} |
|||
{| width=600px class="wikitable" |
{| width=600px class="wikitable" |
||
|- |
|- |
||
Line 20: | Line 22: | ||
| Graphical Interface |
| Graphical Interface |
||
| No |
| No |
||
|- |
|||
| Included modules |
|||
|} |
|} |
||
<br> |
<br> |
||
= Introduction = |
= Introduction = |
||
The ''' |
The poke-a-hole, or short '''pahole''' tool is part of the dwarves tool-set. It dissects data structures in binary object files, showing (otherwise useless) padding and data crossing cachelines, allowing optimization and performance analysis of data structures in user- or kernel-code. |
||
This tool is worthy to be known by any C and Fortran developer -- the article [http://www.catb.org/esr/structure-packing/ The lost Art of Structure Packingg by Eric S. Raymond] provides an in-detail answer, why. |
|||
<br> |
<br> |
||
= Versions and Availability = |
|||
A list of versions currently available on all bwHPC Clusters can be obtained from the |
|||
<br> |
|||
<big> |
|||
[https://cis-hpc.uni-konstanz.de/prod.cis/ Cluster Information System CIS] |
|||
</big> |
|||
{{#widget:Iframe |
|||
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/devel/pahole |
|||
|width=99% |
|||
|height=120 |
|||
}} |
|||
= Documentation = |
= Documentation = |
||
There currently is no web documentation, or tutorial. |
There currently is no web documentation, or tutorial. After loading the module, documentation is provided in the '''man page'''. |
||
<pre>$ man pahole</pre> |
<pre>$ man pahole</pre> |
||
<br> |
<br> |
||
Line 50: | Line 36: | ||
= Basic commands = |
= Basic commands = |
||
== Dissecting data structures == |
|||
You may receive information on the padding and alignment of data structures using <kbd>pahole</kbd>. |
You may receive information on the padding and alignment of data structures using <kbd>pahole</kbd>. |
||
If interested in the data layout pass the option to expand data structures, e.g. the kernel's |
If interested in the data layout pass the option to expand data structures, e.g. the kernel's |
||
Line 83: | Line 70: | ||
</source> |
</source> |
||
This nicely shows, where the compiler needed to insert padding to adhere to the architecture's alignment requirements specified by the ABI. |
This nicely shows, where the compiler needed to insert padding to adhere to the architecture's alignment requirements specified by the ABI. Additionally it layouts the crossing of past cacheline boundaries, which might be problematic in false sharing of cachelines in multi-threaded programming. |
||
Additionally it layouts the crossing of past cacheline boundaries, which might be problematic in false sharing of cachelines in multi-threaded programming. |
|||
Both of this information may be used by You to re-layout your data-structures to minimize them and limit cache-thrashing. |
Both of this information may be used by You to re-layout your data-structures to minimize them and limit cache-thrashing. |
||
== Usage in own application == |
|||
To employ this in your own application, recompile with compiler option <kbd>-g</kbd>. |
|||
For the following code (part of the Open MPI implementation): |
|||
[[Category:debugger software]][[Category:performance analysis software]][[Category:bwUniCluster]] |
[[Category:debugger software]][[Category:performance analysis software]][[Category:bwUniCluster]] |
Revision as of 15:08, 21 February 2022
The main documentation is available via |
Description | Content |
---|---|
module load | devel/pahole |
Availability | bwUniCluster |
License | GPL |
Citing | n/a |
Links | Homepage | Releases |
Graphical Interface | No |
Introduction
The poke-a-hole, or short pahole tool is part of the dwarves tool-set. It dissects data structures in binary object files, showing (otherwise useless) padding and data crossing cachelines, allowing optimization and performance analysis of data structures in user- or kernel-code.
This tool is worthy to be known by any C and Fortran developer -- the article The lost Art of Structure Packingg by Eric S. Raymond provides an in-detail answer, why.
Documentation
There currently is no web documentation, or tutorial. After loading the module, documentation is provided in the man page.
$ man pahole
Basic commands
Dissecting data structures
You may receive information on the padding and alignment of data structures using pahole. If interested in the data layout pass the option to expand data structures, e.g. the kernel's data structure for every single task, use pahole -E task_struct
struct task_struct {
struct thread_info {
long unsigned int flags; /* 0 8 */
unsigned int status; /* 8 4 */
} thread_info; /* 0 16 */
/* XXX last struct has 4 bytes of padding */
volatile long int state; /* 16 8 */
void * stack; /* 24 8 */
struct {
int counter; /* 32 4 */
} usage; /* 32 4 */
unsigned int flags; /* 36 4 */
unsigned int ptrace; /* 40 4 */
/* XXX 4 bytes hole, try to pack */
struct llist_node {
struct llist_node * next; /* 48 8 */
} wake_entry; /* 48 8 */
int on_cpu; /* 56 4 */
unsigned int cpu; /* 60 4 */
/* --- cacheline 1 boundary (64 bytes) --- */
unsigned int wakee_flips; /* 64 4 */
...
}
This nicely shows, where the compiler needed to insert padding to adhere to the architecture's alignment requirements specified by the ABI. Additionally it layouts the crossing of past cacheline boundaries, which might be problematic in false sharing of cachelines in multi-threaded programming. Both of this information may be used by You to re-layout your data-structures to minimize them and limit cache-thrashing.
Usage in own application
To employ this in your own application, recompile with compiler option -g. For the following code (part of the Open MPI implementation):