Code Monkey home page Code Monkey logo

eflambe_live's Introduction

E flambè Live
  • Generate and view flamegraphs in livebook

  • Uses eFlambè to generate flamegraphs

Screenshot and demo

Livebook flamegraph screenshot

The best way to see how it works is to open up the demo in Livebook!

Description

eFlambè integration with Livebook. This tool is designed for rapid profiling of Elixir code in Livebook. The API mirrors the API profiled by :eflambe but the output is displayed as an interactive SVG flamegraph in Livebook using Kino.JS.

Installation

Add the following to the setup block in your livebook to use EflambeLive:

Mix.install([
  {:kino, "~> 0.7.0"},
  {:eflambe_live, "~> 0.1.0"}
])

Usage

There are two ways to profile code with eflambè. You can either invoke the code directly using EflambeLive.apply/1,2 or you can "capture" trace data from a function when it is invoked by another process on the node EflambeLive.capture/1,2,3.

Implementation

For SpawnFest 2021 I created eFlambè. This year I wanted to try extending it to Livebook. eFlambè worked well enough for its intended use, but there were several things that had to be addressed in order to use it from Livebook:

  • eFlambè only wrote flamegraph data to files on disk. There was no API that returned flamegraphs to the caller.

  • The eflambe:capture/3 function was asynchronous so the flamegraph wasn’t even generated when the function returned.

  • eFlambè only generated flamegraphs in formats that required a flamegraph viewer in order to understand.

I addressed these issues in a series of PRs:

  • I redesigned the eFlambè API so function calls were synchronous and would return the name of the file containing the flamegraph data. This PR was done before SpawnFest and is not part of my submission: Stratus3D/eflambe#34

  • Added an option to return the formatted flamegraph data directly: Stratus3D/eflambe#35

  • Added an eFlambè formatter that generated a self-contained interactive SVG file: Stratus3D/eflambe#36

With these things in place there was very little code that needed to be written for EflambeLive. The functions in EflambeLive call corresponding functions in :eflambe and receive SVG data back from them. The code passes the SVG data to Kino.JS which handles rendering the SVG on the page and adding JavaScript and CSS to make the SVG interactive in Livebook.

The JavaScript code that makes the flamegraph interactive was ported from https://github.com/brendangregg/FlameGraph.

This project was inspired by Mike Binn’s https://github.com/DockYard/flame_on project and is very similar.

Contributing

Feedback is welcome! This was started as a hackathon project but I plan on maintaining it for my teams every day use, so if you see something that could be improved please open an issue!

Tagging Releases

  1. Update versions in README.adoc to new version.

  2. Run git add README.adoc.

  3. Use mix hex.publish.

  4. Run git tag <new tag>.

  5. Run git push origin master <new tag>.

eflambe_live's People

Contributors

stratus3d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

zoten

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.