Skip to content

Instantly share code, notes, and snippets.

View deepak's full-sized avatar

Deepak Kannan deepak

View GitHub Profile
@deepak
deepak / gist:356517
Created April 5, 2010 16:08 — forked from tmm1/gist:61762
> - In ruby 1.8.x, what is the functional difference between rb_thread_schedule and rb_thread_select?
rb_thread_schedule() is the guts of the thread scheduler, it traverses
over the linked list of threads (several times) to find the next one
to switch into. The function is long (250 lines) and messy, and covers
all the combinations of thread status (RUNNABLE, TO_KILL, STOPPED,
KILLED) and wait state (FD, SELECT, TIME, JOIN, PID).
If there are no threads doing i/o or waiting on a timeout,
rb_thread_schedule() picks another thread from the list (considering
# Oleg Andreev <[email protected]> Oct 16, 2009
#
# This demonstrates how to perform a request to the same Rails instance without hitting HTTP server.
# Note 1: this does not boot another Rails instance
# Note 2: this does not involve HTTP parsing
# Note 3: dispatch_unlocked and rack.multithread=true are used to prevent deadlock on a dispatch mutex,
# NOT to make inner requests operate concurrently as one may think.
# Note 4: inner request is created by merging outer request with some HTTP headers and rack options.
# This may probably lead to strange effects, so be aware of it.
# Perhaps, we shouldn't use outer request at all. I don't know.
#
# Created by Eric Lindvall <[email protected]>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# For a longer explanation, see my post at:
#
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby
#
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001
From: Ilya Grigorik <[email protected]>
Date: Thu, 10 Jun 2010 00:46:48 -0400
Subject: [PATCH] async rails3
---
Gemfile | 6 ++++++
app/controllers/widgets_controller.rb | 6 ++++++
app/models/widget.rb | 2 ++
config.ru | 1 +
#!/usr/bin/env ruby
#
# Find bloating passengers and kill them gracefully. Run from cron every minute.
#
# required for passenger since cron has no environment
ENV['HTTPD'] = 'httpd'
MEM_LIMIT = ARGV[0] || 500
# Used to graph results from autobench
#
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
#
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
require 'benchmark'
module Kernel
alias old_require require
def require(path)
#unless caller.find { |caller_line| caller_line.match /dependencies\.rb/ }
# return old_require(path)
#end
#
# Created by Eric Lindvall <[email protected]>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# For a longer explanation, see my post at:
#
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby
#
@deepak
deepak / gist:737196
Created December 11, 2010 06:30 — forked from anonymous/gist:734122
forked bcuz it was anonymous (could it be deleted .. dunno)
~/projects/jruby ➔ jmap -histo 19907 | grep rubyobj | head -50
116: 1945 46680 rubyobj.Gem.Version
118: 1898 45552 rubyobj.Gem.Version
120: 1826 43824 rubyobj.Gem.Requirement
123: 1804 43296 rubyobj.Gem.Requirement
158: 914 21936 rubyobj.Gem.Dependency
166: 876 21024 rubyobj.Gem.Dependency
209: 463 11112 rubyobj.Gem.Specification
211: 455 10920 rubyobj.Gem.Specification
319: 142 3408 rubyobj.ActiveSupport.TimeZone