Skip to content

Instantly share code, notes, and snippets.

View pglombardo's full-sized avatar
🕶️

Peter Giacomo Lombardo pglombardo

🕶️
View GitHub Profile
@pglombardo
pglombardo / measure.md
Last active February 23, 2024 00:02
Comprehensive Guide to Ruby Performance Benchmarking

GC.disable

Wall Clock Time versus CPU Time

An important difference to note is the how time is reported by various measurement methods. Wall clock time is the actual time passed in terms of human perception whereas CPU time is the time spent processing the work. CPU time doesn't include any delays waiting on resources to free up such as thread interrupts or garbage collection.

The Work to Measure

To keep things simple, we'll create a Ruby Proc and just repeatedly call that Proc for each of the measurement methods below.

@pglombardo
pglombardo / gist:7630100
Last active May 24, 2022 19:14
How to open your private Github repository and still keep a couple things under wrap

We're happy to say that we recently released the code for the TraceView Ruby instrumentation on Github as Open Source. There are a ton of benefits for AppNeta (and the community) in doing this so making the decision was easy... but the process of actually opening the repository and still keeping a few things private was slightly trickier. Here's the route we took that has worked out really well.

The Situation and Strategy

The Ruby instrumentation has always been sheltered on Github - albeit always in a private Github repository. We used the issues, pull requests and wiki pages extensively for everything from new employee resources to hosting screenshots, customer issues, internal discussions and links to other project and management tools (e.g. Asana).

Outside of the commits and the code, everything else was either of little use to the public or potentially company or customer confidential - stuff that shouldn't or couldn't be shared publicly. So this put us

@pglombardo
pglombardo / 1.8.7-p374.txt
Last active May 16, 2022 12:36
Kernel.caller Performance Across Different Ruby Versions
Backtrace generated 500 times with 1508 frames
Thread ID: 69872793616820
Total Time: 0.377622164
Sort by: total_time
%total %self total self wait child calls Name
--------------------------------------------------------------------------------
100.00% 0.01% 0.378 0.000 0.000 0.378 1 Global#[No method]
0.378 0.000 0.000 0.378 1/301 Object#one
--------------------------------------------------------------------------------
@pglombardo
pglombardo / gist:7206464
Created October 28, 2013 23:11
The War on ActionView with Russian Doll Caching

Rails 4 is out featuring Russian Doll caching (AKA Cache Digests). In this article, I apply Russian Doll caching to one of my poorer performing Rails 3 pages using the cache_digests gem.

ActionView templates are great. They are easy to code, manage and extend but the one thing they are not is fast...at least not out of the box.

In this article, I'll be using AppNeta's TraceView to time ActionView performance. If you haven't used TraceView before, checkout my previous article Instrumenting Ruby on Rails with TraceView.

ActionView is Slow; Pitfalls Ahead

ActionView puts forth a great development pattern of views and partials that is easy to understand, implement and maintain but that comes at a cost: The rendering process is complex and slow.

@pglombardo
pglombardo / x.txt
Created March 4, 2019 10:11
2017 MacBook Pro Crashing on Sleep
Anonymous UUID: 8DD42072-72D6-4761-9A18-9AC8503B209D
Mon Mar 4 11:08:04 2019
*** Panic Report ***
panic(cpu 0 caller 0xffffff7f9aeebcd9): "Failed to complete supporting devices sleep/wake\n"@/Library/Caches/com.apple.xbs/Sources/AppleEmbeddedOSSupport/AppleEmbeddedOSSupport-59.60.8/Source/Drivers/AppleEmbeddedOSSupportHost/AppleEmbeddedOSSupportHost.cpp:460
Backtrace (CPU 0), Frame : Return Address
0xffffff921808be50 : 0xffffff8017ee956c
0xffffff921808bed0 : 0xffffff7f9aeebcd9
0xffffff921808bf00 : 0xffffff8017f2202a
@pglombardo
pglombardo / gist:3105433
Created July 13, 2012 15:16
Overriding Devise Sessions Controller and Setting a Cookie
# config/routes.rb
devise_for :users, :controllers => { :registrations => :sessions => "sessions" }
# app/controllers/sessions_controller.rb
class SessionsController < Devise::SessionsController
# POST /resource/sign_in
def create
cookies[:logged_in_cookie] = "#{SecureRandom.hex(16)}"
super
end
@pglombardo
pglombardo / myfalcon.py
Created July 24, 2018 06:40
Falcon app with Instana WSGI middleware
import falcon
import instana
from instana.wsgi import iWSGIMiddleware
instana.service_name = "Falcon_Service"
# Falcon follows the REST architectural style, meaning (among
# other things) that you think in terms of resources and state
# transitions, which map to HTTP verbs.
@pglombardo
pglombardo / mycherry.py
Last active February 14, 2018 12:27
Adding Instana WSGI middleware to a CherryPy application
import cherrypy
import instana
from instana.wsgi import iWSGIMiddleware
# My CherryPy application
class Root(object):
@cherrypy.expose
def index(self):
return "hello world"
#!/usr/bin/env python
import instana
import tornado.httpserver
import tornado.ioloop
import tornado.web
import opentracing
import opentracing.ext.tags as tags
import logging
instana.service_name = "Tornado 🌪"
#!/usr/bin/env python
import datetime
from functools import wraps
import instana
import tornado.httpserver
import tornado.ioloop
import tornado.ioloop
import tornado.web
import tornado.web