Giter VIP home page Giter VIP logo

xprof's Introduction

XProf Build Status Coverage Status

XProf is a profiler that allows you to track execution time of Erlang functions. It's also able to capture arguments and results of a function calls that lasted longer than given number of milliseconds.

Goal

XProf was created to help solving performance problems of live, highly concurrent and utilized BE systems. It's often the case that high latency or big CPU usage is caused by very specific requests that are triggering inefficient code. Finding this code is usually pretty difficult.

How to use it

Demo

  1. Add xprof to your rebar.config (and optionally to reltool.config in order to include it into your release).
  2. Build your project.
  3. Start xprof by executing xprof:start() in Erlang shell.
  4. Go to http://SERVER:7890.
  5. Type in function that you would like to start tracing.
  6. Start tracing clicking green button.
{deps, [
       ...
       {xprof, ".*", {git, "https://github.com/appliscale/xprof.git"}}
]}.

xprof is available on Hex package manager, so you are able to use it also in the following way:

%% It is possible only with newest version of `rebar3` (at least `3.3.3`):

{deps, [
       ...
       {xprof, "1.1.0"}
]}.
# Inside `mix.exs`:

defp deps do
    [
      ...
      {:xprof, "~> 1.1.0"}
    ]
  end

Configuration

You can configure xprof by changing its application variables:

Key Default Description
port 7890 Port for the web interface

xprof flavoured match-spec funs

CAUTION: Experimental support (WIP).

In the function browser you can also specify further filters in the form of a match-spec fun (similar to recon or redbug). After the module and function name one can also give a function definition instead of arity. This gives the user the full power of match specifications and can be used both to selectively measure duration of function calls that match complicated filters and to capture only part of the arguments. The function has the same limitations as dbg:fun2ms/1. (See Match Specifications in Erlang and ms_transform). The function can be terminated by a single dot or end. and return_trace is always implicitly on (that is how xprof measures duration)

For example only measure the duration of ets:lookup on table data

ets:lookup([data, _]) -> true.

Or only capture the important field of a possibly big data record

ets:insert([_, #data{important = I}]) -> message(I).

Contributing

All improvements, fixes and ideas are very welcomed!

Project uses rebar3 for building and testing erlang code. WebUI part resides in xprof app's priv directory and it's already precompiled so there is no need to build JS sources in order to run xprof.

Running tests

make test

Working with JS sources

The WebUI uses

  • React.js
  • ECMAScript 6 (with elements from 7th version).
  • Bootstap
  • Bower
  • Webpack

All sources are in priv directory. The app folder contains the sources and the build folder is a placeholder for final JS generated by webpack and then served by cowboy server (XProf's dependency).

Starting xprof in development mode

To develop xprof in convenience following setup is recommended.

You have to invoke following command once, if you do not have dependencies or you need to update them:

$ make bootstrap_front_end

Then going with normal development flow - in the first terminal window start Erlang xprof by calling make dev. The sync app will be started, It automatically reloads erlang modules that have changed, so you don't need to recompile everytime something changed.

$ make dev

In the second window install all the assets and start webpack in development mode which is also going to recompile all JS files in priv directory when they are modified. To achieve that use following command:

$ make webpack_autoreload

xprof's People

Contributors

afronski avatar gomoripeti avatar mniec avatar ppikula avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.