All Projects → amzn → Hawktracer

amzn / Hawktracer

Licence: mit
HawkTracer is a highly portable, low-overhead, configurable profiling tool built in Amazon Video for getting performance metrics from low-end devices.

Projects that are alternatives of or similar to Hawktracer

Caliper
Caliper is an instrumentation and performance profiling library
Stars: ✭ 162 (+50%)
Mutual labels:  instrumentation, performance-monitoring, performance
Inspectit
inspectIT is the leading Open Source APM (Application Performance Management) tool for analyzing your Java (EE) applications.
Stars: ✭ 513 (+375%)
Mutual labels:  instrumentation, performance
Watchdoginspector
Shows your current framerate (fps) in the status bar of your iOS app
Stars: ✭ 497 (+360.19%)
Mutual labels:  performance-monitoring, performance
Automon
Automon combines the power of AOP (AspectJ) with monitoring or logging tools you already use to declaratively monitor your Java code, the JDK, and 3rd party libraries.
Stars: ✭ 548 (+407.41%)
Mutual labels:  performance-monitoring, performance
Ava
Node.js test runner that lets you develop with confidence 🚀
Stars: ✭ 19,458 (+17916.67%)
Mutual labels:  hacktoberfest, performance
Guider
Performance Analyzer
Stars: ✭ 393 (+263.89%)
Mutual labels:  hacktoberfest, performance
React Esi
React ESI: Blazing-fast Server-Side Rendering for React and Next.js
Stars: ✭ 537 (+397.22%)
Mutual labels:  hacktoberfest, performance
Wipe Modules
🗑️ Easily remove the node_modules folder of non-active projects
Stars: ✭ 304 (+181.48%)
Mutual labels:  hacktoberfest, performance
Guess
🔮 Libraries & tools for enabling Machine Learning driven user-experiences on the web
Stars: ✭ 6,762 (+6161.11%)
Mutual labels:  hacktoberfest, performance
Image Actions
A Github Action that automatically compresses JPEGs, PNGs and WebPs in Pull Requests.
Stars: ✭ 844 (+681.48%)
Mutual labels:  performance-monitoring, performance
Lozad.js
🔥 Highly performant, light ~1kb and configurable lazy loader in pure JS with no dependencies for responsive images, iframes and more
Stars: ✭ 6,932 (+6318.52%)
Mutual labels:  hacktoberfest, performance
Predator
A powerful open-source platform for load testing APIs.
Stars: ✭ 356 (+229.63%)
Mutual labels:  hacktoberfest, performance
App perf
Open source application performance monitoring tool with emphasis on ease of setup and use. Providing similar functionality like NewRelic/AppNeta/Skylight etc.
Stars: ✭ 353 (+226.85%)
Mutual labels:  performance-monitoring, performance
Processhacker
A free, powerful, multi-purpose tool that helps you monitor system resources, debug software and detect malware.
Stars: ✭ 6,285 (+5719.44%)
Mutual labels:  performance-monitoring, performance
Rails performance
Monitor performance of you Rails applications
Stars: ✭ 345 (+219.44%)
Mutual labels:  performance-monitoring, performance
Bigcache
Efficient cache for gigabytes of data written in Go.
Stars: ✭ 5,304 (+4811.11%)
Mutual labels:  hacktoberfest, performance
Phpspy
Low-overhead sampling profiler for PHP 7+
Stars: ✭ 1,105 (+923.15%)
Mutual labels:  hacktoberfest, performance
Kubectl Flame
Kubectl plugin for effortless profiling on kubernetes
Stars: ✭ 297 (+175%)
Mutual labels:  hacktoberfest, performance
Hint
💡 A hinting engine for the web
Stars: ✭ 3,280 (+2937.04%)
Mutual labels:  hacktoberfest, performance
Sinuous
🧬 Light, fast, reactive UI library
Stars: ✭ 740 (+585.19%)
Mutual labels:  hacktoberfest, performance

Build Status Gitter chat Codacy Badge codecov Build status

HawkTracer

HawkTracer is a highly portable, low-overhead, configurable profiling tool built in Amazon Video for getting performance metrics from low-end devices.

HawkTracer is available on most popular platforms: Linux, Windows, OS X. By default, the library can be used with C and C++, but there are also wrappers for Python and Rust.

The library provides many different types of events (e.g. CPU usage event, duration tracepoint), but the list can easily be extended by the user.

Features

  • Low CPU/memory overhead
  • Multi-platform
  • Highly configurable on runtime
  • Easy build integration (CMake & pkg-config files)
  • Pre-defined and user-defined events
  • Simple macros for code instrumentation
  • Streaming events to file, through TCP/IP protocol, or handling them in custom function
  • Client for receiving event stream
  • Library for parsing event stream (so you can write your own client)

License Summary

This sample code is made available under the MIT license. (See LICENSE file)

Getting Started

Hello World! tutorials

See the tutorial to quickly onboard to HawkTracer or check the examples directory. The tutorial step by step explains how to build and instrument the code like that:

static void hello_world()
{
    HT_G_TRACE_FUNCTION()

    for (int i = 0; i < 100; i++)
    {
        HT_TP_G_STRACEPOINT("iteration")
        printf("2 * %d = %d\n", i, 2*i);

        std::string txt = "Iteration (mod 10): " + std::to_string(i % 10);
        HT_TP_G_DYN_STRACEPOINT(txt.c_str());
        printf("text: %s\n", txt.c_str());
    }
}

You can also follow instructions below to get HawkTracer up and running.

Building library

$ mkdir build       # It'll be different on Windows
$ cd build
$ cmake ..
$ cmake --build .   # This instead of make, so we don't need extra instructions for Windows

Attaching HawkTracer to a project to profile

Build system integration

CMake-based projects

If you use CMake build system, you can use following code to attach HawkTracer library to your project:

project(your_project)

# optionally, you might define a path to HawkTracer's CMake module
# CMake the path below should be a path to a directory where HawkTracerConfig.cmake is located, e.g.:
# list(APPEND CMAKE_MODULE_PATH "/usr/local/lib/cmake/HawkTracer")

find_package(HawkTracer REQUIRED)

add_executable(your_project main.cc)

target_link_libraries(your_project HawkTracer::hawktracer)

pkg-config

HawkTracer library provides pkg-config file which can be used to find required libraries and include paths. You can simply integrate it e.g. with your compilation command:

$ g++ my_project.cpp $(pkg-config --cflags --libs hawktracer)

Instrumenting code

Initialize library

Before you start profiling your code, you need to initialize HawkTracer library. There are 2 functions which always have to be called in projects profiled by HawkTracer: ht_init and ht_deinit. Additionally, you need to specify an event listener. HawkTracer currently provides 2 listeners:

  • TCP listener, which streams events over the network
  • File dump listener, which saves events to a file.

Moreover, HawkTracer allows to provide user-defined listeners. Code below presents example HawkTracer (un)initialization:

int main(int argc, char** argv)
{
  ht_init(argc, argv); // initialize library
  HT_Timeline* timeline = ht_global_timeline_get(); // timeline, where all events are posted. You can define your own timeline, or use global timeline
  const size_t buffer_size = 4096; // size of internal listener's buffer
  ht_file_dump_listener_register(ht_global_timeline_get(), "hello-world-out.htdump", 2048, NULL); // create listener and attach it to timeline

  // your code goes here...

  ht_deinit(); // uninitialize library

  return 0;
}

The code registers file dump listener, which saves all the events to a file file_name.htdump. The file should be then converted to a viewer's format (see here for details).

Instrumenting the code

HawkTracer requires explicit code instrumentation. The library provides a few helper macros for reporting data to a timeline:

// Pushes any type of event to a timeline
HT_TIMELINE_PUSH_EVENT(TIMELINE, EVENT_TYPE, EVENT_PARAMETERS,...)

// Reports a duration of specific block of code (available only for C++ or C GNU compiler)
HT_TRACE(TIMELINE, LABEL)

// The same as above, but automatically sets label to current function name
HT_TRACE_FUNCTION(TIMELINE)

There are few macros which report events to a global timeline, they're prefixed with G_:

HT_G_TRACE(LABEL)
HT_G_TRACE_OPT_STATIC(LABEL)
HT_G_TRACE_OPT_DYNAMIC(LABEL)
HT_G_TRACE_FUNCTION()

For example, you can instrument following code:

void foo()
{
  HT_G_TRACE_FUNCTION() // measure duration of foo function execution

  for (int i = 0; i < 100; i++)
  {
    HT_G_TRACE_OPT_STATIC("in-loop") // measure duration of single loop iteration
    bar();
  }
}

Collect the data

For now HawkTracer provides a simple application for converting event stream to a JSON format which can be consumed by the viewing application: hawktracer-to-json. You can use it with a file or with a network stream. Assuming your events have been saved to file_name.htdump file, you can generate the JSON file running following command:

hawktracer-to-json --source file_name.htdump --output output_file.json

Analyzing the data

  • Install google-chrome or chromium browser
  • Open the browser, and open chrome://tracing/ webpage
  • Click load button and open file generated in the previous section
  • You should see a callstack with timing

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Acknowledgment

  • Hat tip to anyone who's code was used
  • Inspiration
  • etc
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].