Package: timemory
timemoryTiming + Memory + Hardware Counter Utilities for C / C++ / CUDA / Pythontimemory on GitHub (Source code)timemory General Documentation (ReadTheDocs)timemory Source Code Documentation (Doxygen)timemory Testing Dashboard (CDash)timemory Tutorialstimemory WikiGitHubgit clone https://github.com/NERSC/timemory.gitPyPipip install timemorySpackspack install timemoryPurposeThe goal of timemory is to create an open-source performance measurement and analyis package
with modular and reusable components which can be used to adapt to any existing C/C++
performance measurement and analysis API and is arbitrarily extendable by users within their
application.
Timemory is not just another profiling tool, it is a proflingtoolkitwhich streamlines building custom
profiling tools through modularity and then utilizes the toolkit to provides several pre-built tools.In other words, timemory provides many pre-built tools, libraries, and interfaces but, due to it's modularity,
codes can re-use only individual pieces -- such as the classes for measuring different timing intervals, memory usage,
and hardware counters -- without the timemory "runtime management".Building and InstallingTimemory uses a standard CMake installation.
Several installation examples can be found in theWiki. See theinstallation documentationfor detailed information on the CMake options.DocumentationThe full documentation is available attimemory.readthedocs.io.
Detailed source documentation is provided in thedoygensection of the full documentation.
Tutorials are available in thegithub.com/NERSC/timemory-tutorials.OverviewThe primary objective of the timemory is the development of a common framework for binding together software
monitoring code (i.e. performance analysis, debugging, logging) into a compact and highly-efficient interface.Timemory arose out of the need for a universal adapator kit for the various APIs provided several existing tools
and a straight-forward and intuitive method for creating new tools. Timemory makes it possible to bundle
together deterministic performance measurements, statistical performance
measurements (i.e. sampling), debug messages, data logging, and data validation into the same interface for
custom application-specific software monitoring interfaces, easily building tools liketime,netstat, instrumentation profilers, sampling profilers, and writing implementations for MPI-P, MPI-T, OMPT,
KokkosP, etc.Timemory provides a front-endC/C++/Fortran APIandPython APIwhich allows arbitrary selection
of 50+ different components from timers to hardware counters to interfaces with third-party tools. This is all
built generically from the toolkit API with type-safe bundles of tools such as:component_tuple<wall_clock, papi_vector, nvtx_marker, user_bundle>wherewall_clockis a wall-clock timer,papi_vectoris a handle for hardware counters,nvxt_markercreates notations in the NVIDIA CUDA profilers, anduser_bundleis a generic component which downstream users can insert more components into at runtime.Performance measurement components written with timemory are arbitrarily scalable up to any number of threads and
processes and fully support intermixing different measurements at different locations within the program -- this
uniquely enables timemory to be deployed to collect performance data at scale in HPC because highly detailed collection can
occur at specific locations within the program where ubiquitous collection would simulatenously degrade performance
significantly and require a prohibitive amount of memory.Timemory can be used as a backend to bundle instrumentation and sampling tools together, support serialization to JSON/XML,
and provide statistics among other uses. It can also be utilized as a front-end to invoke
custom instrumentation and sampling tools. Timemory uses the abstract term "component" for a structure
which encapsulates some performance analysis operation. The structure might encapsulate function
calls to another tool, record timestamps for timing, log values provided by the application,
provide a operator for replacing a function in the code dynamically, audit the incoming arguments
and/or outgoing return value from function, or just provide stubs which can be overloaded by the linker.Visualization and AnalysisThe native output format of timemory is JSON and text; other output formats such as XML are also supported.
The text format is intended to be human readable. The JSON data
is intended for analysis and comes in two flavors: hierarchical and flat. Basic plotting capabilities are
available viatimemory-plottingbut users are highly encouraged to usehatchetfor analyzing the heirarchical JSON data in pandas dataframes.Hatchetsupports
filtering, unions, addition, subtractions, output todotand flamegraph formats, and an interactive Jupyter notebook.
At present, timemory supports 45+ metric types for analysis in Hatchet.CategoriesThere are 4 primary categories in timemory: components, operations, bundlers, and storage. Components provide
the specifics of how to perform a particular behavior, operations provide the scaffold for requesting that
a component perform an operation in complex scenarios, bundlers group components into a single generic handle,
and storage manages data collection over the lifetime of the application. When all four categories are combined,
timemory effectively resembles a standard performance analysis tool which passively collects data and provides
reports and analysis at the termination of the application. Timemory, however, makes itvery easyto subtract
storage from the equation and, in doing so, transforms timemory into a toolkit for customized data collection.ComponentsIndividual classes which encapsulate one or more measurement, analysis, logging, or third-party library action(s)Any data specific to one instance of performing the action is stored within the instance of the classAny configuration data specific to that type is typically stored within static member functions which return a reference to the configuration dataThese classes are designed to support direct usage within other tools, libraries, etc.Examples include:tim::component::wall_clock: a simple wall-clock timertim::component::vtune_profiler: a simple component which turns the VTune Profiler on and off (when VTune is actively profiling application)tim::component::data_tracker_integer: associates an integer values with a label as the application executes (e.g. number of loop iterations used somewhere)tim::component::papi_vector: uses the PAPI library to collect hardware-counters valuestim::component::user_bundle: encapsulates an array of components which the user can dynamically manipulate during runtimeOperationsTemplated classes whose primary purpose is to provide the implementation for performing some action on a component, e.g.tim::operation::start<wall_clock>will attempt to call thestart()member function on awall_clockcomponent instanceDefault implementations generally have one or two public functions: a constructor and/or a function call operatorThese generally accept any/all arguments and use SFINAE to determine whether the operation can be performed with or without the given arguments (i.e. doeswall_clockhave astore(int)function?store()?)Operations are (generally) not directly utilized by the user and are typically optimized out of the binaryExamples include:tim::operation::start: instruct a component to start collectiontim::operation::sample: instruct a component to take individual measurementtim::operation::derive: extra data from other components if it is availableBundlersProvide a generic handle for multiple componentsMember functions generally accept any/all arguments and use operations classes to correctly to handle differences between different capabilities of the components it is bundlingExamples include:tim::auto_tupletim::component_tupletim::component_listtim::lightweight_tupleVarious flavors provide different implicit behaviors and allocate memory differentlyauto_tuplestarts all components when constructed and stops all components when destructed whereascomponent_tuplerequires an explicit startcomponent_tupleallocates all components on the stack and components are "always on" whereascomponent_listallocates components on the heap and thus components can be activated/deactivated at runtimelightweight_tupledoes not implicitly perform any expensive actions, such as call-stack tracking in "Storage"StorageProvides persistent storage for multiple instances of components over the lifetime of a thread in the applicationResponsible for maintaining the hierarchy and order of component measurements, i.e. call-stack trackingResponsible for combining component data from multiple threads and/or processes and outputting the resultsNOTE:tim::lightweight_tupleis the recommended bundle for those seeking to use timemory as a toolkit for implementing custom tools and interfacesFeaturesC++ Template APIModular and fully-customizableAdheres to C++ standard template library paradigm of "you don't pay for what you don't use"Simplifies and facilitates creation and implementation of performance measurement toolsCreate your own instrumentation profilerCreate your own instrumentation libraryCreate your own sampling profilerCreate your own sampling libraryCreate your own execution wrappersSupplement timemory-provided tools with your own custom component(s)Thread-safe data aggregationAggregate collection over multiple processes (MPI and UPC++ support)Serialization to text, JSON, XMLComponents are composable with other componentsVariadic component bundlers which maintain complete type-safetyComponents can be bundled together into a single handle without abstractionsComponents can store data in any valid C++ data typeComponents can return data in any valid C++ data typeC / C++ / CUDA / Fortran Library APIStraight-forward collection of functions and macros for creating built-in performance analysis to your codeComponent collection can be arbitrarily inter-mixedE.g. collect "A" and "B" in one region, "A" and "C" in another regionComponent collection can be dynamically manipulated at runtimeE.g. add/remove "A" at any point, on any thread, on any processPython APIDecorators and context-managers for functions or regions in codePython function profilingPython line-by-line profilingEvery component intimemory-availis provided as a stand-alone Python classProvide low-overhead measurements for building your own Python profiling toolsPython Analysis viapandasCommand-line Toolstimemory-availProvides available components, settings, and hardware countersQuick API reference tooltimem(UNIX)Extended version of UNIXtimecommand-line tool that includes additional information on memory usage, context switches, and hardware countersSupport collecting hardware counters (Linux-only, requires PAPI)timemory-run(Linux)Dynamic instrumentation profiling toolSupports runtime instrumentation and binary re-writingtimemory-nvmlData collection similar tonvidia-smitimemory-python-profilerPython function profiler supporting all timemory componentsfrom timemory.profiler import Profiletimemory-python-tracePython line-by-line profiler supporting all timemory componentsfrom timemory.trace import Tracetimemory-python-line-profilerPython line-by-line profiler based online-profilerpackageExtended to use components: cpu-clock, memory-usage, context-switches, etc. (all components which collect scalar values)from timemory.line_profiler import LineProfilerInstrumentation Librariestimemory-mpip: MPI Profiling Library (Linux-only)timemory-ncclp: NCCL Profiling Library (Linux-only)timemory-ompt: OpenMP Profiling Librarytimemory-compiler-instrument: Compiler instrumentation Librarykokkos-connector: Kokkos Profiling LibrariesVersioningTimemory originated as a very simple tool for recording timing and memory measurements (hence the name) in C, C++, and Python and only supported
three modes prior to the 3.0.0 release: a fixed set of timers, a pair of memory measurements, and the combination of the two.Prior to the 3.0.0 release, timemory was almost completely rewritten from scratchwith the sole exceptions of some C/C++ macro, e.g.TIMEMORY_AUTO_TIMER, and some Python decorators and context-manager, e.g.timemory.util.auto_timer, whose behavior were
able to be fully replicated in the new release. Thus, while it may appear that timemory is a mature project at v3.0+, it
is essentially still in it's first major release.Citing timemoryTo reference timemory in a publication, please cite the following paper:Madsen, J.R. et al. (2020) Timemory: Modular Performance Analysis for HPC. In: Sadayappan P., Chamberlain B., Juckeland G., Ltaief H. (eds) High Performance Computing. ISC High Performance 2020. Lecture Notes in Computer Science, vol 12151. Springer, ChamAdditional InformationFor more information, refer to thedocumentation.