• Stars
    star
    357
  • Rank 114,882 (Top 3 %)
  • Language
    Ruby
  • License
    MIT License
  • Created about 10 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A new profiler for Ruby. With a GUI

Rbkit

[WARNING]

This project is not maintained at the moment. We have plans to work on a universal profiling protocol after which we intend to rewrite major parts of Rbkit.

Join the chat at https://gitter.im/code-mancers/rbkit

Gem Version Build Status

rbkit is a Ruby gem that plugs into your ruby process, taps profiling data in realtime and sends it across the wire to the rbkit-client as packed messages.

Usage

Install prerequisites

Rbkit requires the following executables to be present :

  • libtool
  • autoconf
  • automake

Install these with your operating system's package manager before proceeding to install Rbkit gem.

Add rbkit to Gemfile

Add the following to the project's Gemfiles

gem 'rbkit', path: <RBKIT_PATH>

and run bundle install

Installation without Rubygems

You can also install rbkit without bundler/rubygems. This can be useful, if you are profiling a Ruby app where you want to measure overhead of Rubygems/Bundler.

Just clone the repository or download from a release tag and run:

# Run from root of rbkit directory.
~> ruby setup.rb

This should install rbkit in ruby's site_dir and then you don't need rbkit added to your Gemfile for requiring rbkit.

Inject rbkit into code

Wherever you want to start profiling, add the following :

require 'rbkit' # Not needed in Rails
Rbkit.start_server

If using Rails, and you want to measure everything from the boot process, a good place to put this would be at the end of config/boot.rb.

Rbkit API

Rbkit.start_server

Without any arguments, it's same as :

Rbkit.start_server(pub_port: nil, request_port: nil)

Starts the Rbkit server and waits for a client to connect and issue commands to the request_port, until then there's zero performance overhead. Profiling data is sent asynchronously over pub_port. This method can be called early in a ruby application so that whenever profiling needs to be done, the client can attach itself to the inactive server, do the profiling and leave. Returns an instance of Rbkit::Server if server was started successfully, else returns false.

argument valid values default value description
pub_port nil, fixnum nil Override default message publishing port of 5555
request_port nil, fixnum nil Override default command listener port of 5556

Rbkit.start_profiling

Without any arguments, it's same as :

Rbkit.start_profiling(
  pub_port: nil,
  request_port: nil,
  enable_object_trace: true,
  enable_gc_stats: true,
  enable_cpu_profiling: true,
  clock_type: :wall,
  cpu_profiling_mode: :sampling,
  cpu_sampling_interval_usec: 1000
)

Starts the server with all tracepoints enabled by default. User can optionally disable tracepoints using the optional arguments. This method can be used to profile the startup process of a ruby application where sending commands from the client to enable profiling is not feasible. Returns an instance of Rbkit::Server if server was started successfully, else returns false.

Arguments:

argument valid values default value description
pub_port nil, fixnum nil Override default message publishing port of 5555
request_port nil, fixnum nil Override default command listener port of 5556
enable_object_trace true/false true Enables object creation/deletion events
enable_gc_stats true/false true Enables GC stats which is sent every 5 seconds
enable_cpu_profiling true/false true Enables CPU profiling
clock_type :wall/:cpu :wall Specifies clock type to use in CPU profiling
cpu_profiling_mode :sampling :sampling CPU profiling mode - currently only sampling
cpu_sampling_interval_usec Fixnums 1000 CPU Sampling interval un usec, if sampling mode

Development

Install zmq and msgpack

If zmq and msgpack are not installed, Rbkit automatically downloads and installs the two libraries from source during gem installation. But if you are developing Rbkit, it makes sense to have these preinstalled:

On OSX - Using homebrew following command should suffice:

~> brew install zeromq
~> brew install msgpack

On Linux - we recommend to download these libraries from their respective home pages and manually compiling and installing.

Recommended versions are:

Zeromq: 4.0.5_2 Msgpack: 0.5.9

Clone the repo

git clone [email protected]:code-mancers/rbkit.git

We'll call this <RBKIT_PATH>.

Set RBKIT_DEV environment flag

Set the environment variable RBKIT_DEV to true. If using bash, put export RBKIT_DEV=true in your ~/.bashrc.

This compiles the C extension with debug flag and also sets a macro named RBKIT_DEV inside the C extension.

Compile the C extension

Two ways to do this :

Using rake
cd <RBKIT_PATH>
bundle install
bundle exec rake compile

Or do it manually
cd <RBKIT_PATH/ext>
ruby extconf.rb
make
# Create a symlink at `lib/rbkit_server.bundle` (or .so if on linux)
# that points to `ext/rbkit_server.bundle`
# (in order to use `rbkit` gem in Gemfiles using `path` option)

Run the tests

bundle exec rake

TODO

TODOs are tracked as github issues.

More Repositories

1

invoker

An awesome utility to manage all your processes in development environment
Ruby
460
star
2

rapidfire

Making dynamic surveys should be easy!
Ruby
308
star
3

interceptor

A browser extension to mock AJAX requests at the browser level
TypeScript
199
star
4

restful_route_version

A Rails plugin to allow versioning of restful routes
Ruby
42
star
5

rbkit-client

Rbkit Desktop application
C++
32
star
6

rapidfire-app

Rails app for managing surveys
Ruby
16
star
7

ministry_of_state

Modern ActiveRecord state machine plugin
Ruby
15
star
8

borg

A distributed Test Suite runner for Rails, using Eventmachine and Redis
Ruby
15
star
9

toothpick

For the fine art of picking
Ruby
12
star
10

rails_legit

Provides a DSL for common validation use-cases like Date, Array, DateTime etc.
Ruby
12
star
11

rspec-simple

A simple rspec mode for emacs
Emacs Lisp
11
star
12

picks

Daily collection of Codemancers picks
6
star
13

rails-mailgun

Rails integration for Mailgun service
Ruby
6
star
14

rpbundle

Use Gemfiles in your ruby-processing sketches
Ruby
6
star
15

reddit-web

An alternative interface to Reddit.
JavaScript
5
star
16

bitbucket.ex

Elixir lib for Bitbucket v2.0 APIs
Elixir
4
star
17

hubot-pr-fu

Commands for working with open Github PRs for a repo
CoffeeScript
4
star
18

sicp

another attempt at sicp book
Clojure
3
star
19

phoenix-distillery-blogpost-example

JavaScript
3
star
20

invoker-app

A systemtray/menubar app to easily manage invoker
JavaScript
3
star
21

strapi-plugin-stellate

Strapi Plugin Stellate is a plugin for the Strapi headless CMS that provides a convenient way to purge the cache.
JavaScript
3
star
22

rbkit-electron-redux

Electron Client that connects to Rbkit
JavaScript
2
star
23

hctbox-demo

Demo app for hctbox gem
Ruby
2
star
24

littil.ext

Littil's browser extensions for firefox and chrome browsers
JavaScript
2
star
25

hctbox

HTML CSS Toolbox: still WIP, not even alpha!
Ruby
2
star
26

rubyconfindia_talk_extensions

C Extension code used for the talk
C
2
star
27

json_schema_sample_app

A sample Sinatra app demonstrating the usage of JSON Schema specification
Ruby
2
star
28

wufoo-assets

CSS
1
star
29

diffity.rb

ruby gem to integrate with integration-diff
Ruby
1
star
30

nudge

Nudge · Without bells and whistles
Elixir
1
star
31

elixir-exit-handling

Elixir
1
star
32

gitlab-dependabot-example

Rails app that simply shows your Gitlab Repositories and later on adds dependabot service to them
Ruby
1
star
33

rbkit-chartjs

experimenting with rbkit-chartjs
JavaScript
1
star
34

blogstyles

CSS
1
star
35

webpack-cheatsheet

A repository for webpack config/documentation and to track and help issues with our webpack setup or frontend setup in general.
JavaScript
1
star
36

invoker.el

An Emacs package for managing invoker
Emacs Lisp
1
star
37

rbkit-chrome

Rbkit Client in the form of a Google Chrome extension
JavaScript
1
star
38

exray

A tool to visualize Erlang/Elixir process related events
Elixir
1
star
39

frisk

Because nobody trusts APIs before you frisk them
Ruby
1
star
40

pr_wooster

A Jenkins plugin that displays pull request status on github
Java
1
star
41

android-notification-receiver

Receives SMS notification (only SMS for now) and displays in a list.
Java
1
star
42

rbkit-atom

Clone of rbkit-client that uses atom-shell
JavaScript
1
star