Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: PIN-based Tracer engine with visualizations #157

Draft
wants to merge 14 commits into
base: devel
Choose a base branch
from

Conversation

PeterMocary
Copy link

@PeterMocary PeterMocary commented Jan 31, 2024

Introduces a new Tracer engine implemented using the Intel's PIN framework
and new visualizations. The PIN based tracer supports three modes of
execution: time, memory and instructions.

  • time mode - allows collection of function (and basic block)
    run-times as well as collection of simple function arguments. The time
    mode is collects only information about functions by default and
    collection of basic blocks needs to be explicitly enabled. It also
    provides option to collect information only about basic blocks
    and infer the function run-times based on them instead.

  • memory mode - allows collection of information about memory
    manipulation functions (malloc, calloc, realloc, new, free and delete
    are supported). This includes collection of their arguments and location
    as well as the return values.

  • instruction mode - allows collection of number of executed
    instructions in basic blocks (and functions). This mode collects basic
    blocks only.

Execution examples:

perun collect -c <cmd> trace -e pin --mode <mode-name>
perun collect -c <cmd> trace -e pin --mode time --collect-basic-blocks
perun collect -c <cmd> trace -e pin --mode time --collect-arguments
perun collect -c <cmd> trace -e pin --mode time --collect-basic-blocks-only

The three new visualizations introduced are: basicblocks,
funcargs, and treemap.

  • basicblocks visualization - a sunburst graph that contains
    run-times (or number of executions) of functions with their basic
    blocks. It supports basic mapping of the basic blocks to the source
    code. The mapping is, however bit tricky to incorporate into the graph,
    thus treemap visualization utilizing different library was created.
    This visualization uses old version of bokehlibrary and might be retired
    in the future.

  • funcargs visualization - a scatter graph that shows dependency
    between function run-time and values of collected arguments.

  • treemap visualization - has multiple forms of representation as a
    graph: tree-map, sunburst, and flame graph. Each visualizes
    the call graph as a tree in a slightly different way. It supports
    mapping of basic blocks to source code.

Execution examples:

perun show <profile> <visualization-name>
perun show 0@p funcargs --function-name <function-name>
perun show <path-to-profile-or-profile-name>funcargs --function-name <function-name>
perun show 0@p basicblocks --top-functions 5 --top-basic-blocks 5 --sort-by execs
perun show 0@p treemap --graph-type sunburst
perun show 0@p treemap --basic-blocks

How to setup pin:

wget https://software.intel.com/sites/landingpage/pintool/downloads/pin-external-3.31-98861-g71afcc22f-gcc-linux.tar.gz
tar -xvzf ./pin-external-3.31-98861-g71afcc22f-gcc-linux.tar.gz
export PIN_ROOT="$(pwd)/pin-external-3.31-98861-g71afcc22f-gcc-linux"

TODO:

  • refactoring and fixes
    • fix the instructions mode parser
    • fix the basic blocks only parser
  • rebase
  • add tests for pin based tracer engine
  • add tests for visualizations
  • fix typing
  • how to setup guide
  • create issues that need to be addressed in future
    • pick better names for visualizations
    • address todos for exceptions
    • merging the time and instructions parsers into duration parser?

@PeterMocary PeterMocary force-pushed the pin-tracer-and-visualizations branch from 204c608 to 067e3e5 Compare April 2, 2024 19:12
@PeterMocary PeterMocary force-pushed the pin-tracer-and-visualizations branch 3 times, most recently from 04ae5a5 to f197f03 Compare July 21, 2024 13:32
@PeterMocary PeterMocary force-pushed the pin-tracer-and-visualizations branch from f197f03 to af7f366 Compare August 1, 2024 14:57
@PeterMocary
Copy link
Author

There is currently a problem with using hash tables with PIN kit and g++ 12 and newer. The standard library within the kit triggers an uninitialized variable warning that is treated as error by default. Therefore I added a pragma to ignore this warning until the problem is resolved by the PIN kit developers.

Introduces a new Tracer engine implemented using the Intel's PIN
framework. The PIN based tracer supports three modes of execution: time,
memory and instructions.

The time mode allows collection of function (and basic block)
run-times as well as collection of simple function arguments. The time
mode is collects only information about functions by default and
collection of basic blocks needs to be explicitly enabled. It also
provides option to collect information only about basic blocks
and infer the function run-times based on them instead.

The memory mode allows collection of information about memory
manipulation functions (malloc, calloc, realloc, new, free and delete
are supported). This includes collection of their arguments and location
as well as the return values.

The instruction mode allows collection of number of executed
instructions in basic blocks (and functions). This mode collects basic
blocks only.
Three new visualizations are introduced in this commit: basicblocks,
funcargs, and treemap.

The basicblocks visualization is a sunburst graph that contains
run-times (or number of executions) of functions with their basic
blocks. It supports basic mapping of the basic blocks to the source
code. The mapping is, however bit tricky to incorporate into the graph,
thus treemap visualization utilizing different library was created.
This visualization uses old version of bokehlibrary and might be retired
in the future.

The funcargs visualization is a scatter graph that shows dependency
between function run-time and values of collected arguments.

The treemap visualization has multiple forms of representation as a
graph: tree-map, sunburst, and flame graph. Each visualizes
the call graph as a tree in a slightly different way. It supports
mapping of basic blocks to source code.
There is a variable in the standard library of C++ within PIN kit that
causes uninitialized warning to trigger when using g++ 12 and newer.
Since the kit treats warnings as errors by default, the pragma to ignore
this warning was added until the release of new PIN kit with this issue
fixed is released.
Copy link

codecov bot commented Sep 1, 2024

Codecov Report

Attention: Patch coverage is 19.72789% with 354 lines in your changes missing coverage. Please review.

Project coverage is 95.87%. Comparing base (02b625f) to head (e96c17d).

Files with missing lines Patch % Lines
perun/view/basicblocks/run.py 13.36% 188 Missing ⚠️
perun/view/treemap/run.py 16.96% 93 Missing ⚠️
perun/view/funcargs/run.py 16.66% 70 Missing ⚠️
perun/utils/exceptions.py 83.33% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            devel     #157      +/-   ##
==========================================
- Coverage   99.07%   95.87%   -3.20%     
==========================================
  Files         150      156       +6     
  Lines       10470    10910     +440     
==========================================
+ Hits        10373    10460      +87     
- Misses         97      450     +353     
Flag Coverage Δ
coverage-3.10 95.87% <19.72%> (-3.20%) ⬇️
coverage-3.11 95.87% <19.72%> (-3.20%) ⬇️
coverage-3.12 95.86% <19.72%> (-3.21%) ⬇️
coverage-3.9 95.86% <19.72%> (-3.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant