Skip to content

Instantly share code, notes, and snippets.

At Monmouth Telecom we provide high-availability cloud based telephone systems for medium to large companies. Because
we have written our own code in Ruby it is easy for us to customize or add additional features at the request of customers,
often at no charge, and that is key to our business.
Several years ago our engineering team developed a real time display panel for managers and operators alike that kept people
abreast of the status of phone extensions, conference bridges, and call queues, as well as allowing a variety of call control
features. We wrote this in ruby so that it would be easy to extend. The web display panel accesses customer data through
Active Record and is based on HTML5 with canvas and web sockets so it doesn’t require setup on the customer site.
Unsurprisingly it was one our more popular features and so we immediately started monitoring Rubinius as our migration path
for the day when one core of our 8 processor cores would become insufficient to meet demand. Well earlier this year
@kwleland
kwleland / gist:f1619d74e1ee769108ab
Created May 12, 2015 18:03
Thread Basher Hang after 2 hours - gdb thread bt
Script started on Tue 12 May 2015 01:44:04 PM EDT
[root@ops ~]# gdb -p 30764
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
@kwleland
kwleland / gist:b28246da9e48aa596293
Created May 11, 2015 17:58
GC Hang Repro thread bt
Starting program: /usr/bin/rbx ./t.rb
[Thread debugging using libthread_db enabled]
[New Thread 0x7fffef301700 (LWP 6838)]
[New Thread 0x7fffeef00700 (LWP 6839)]
[New Thread 0x7fffeeaff700 (LWP 6840)]
[New Thread 0x7fffee6fe700 (LWP 6841)]
[New Thread 0x7fffee2fd700 (LWP 6842)]
[New Thread 0x7fffedefc700 (LWP 6843)]
[New Thread 0x7fffecec7700 (LWP 6844)]
[New Thread 0x7ffff6179700 (LWP 6847)]
@kwleland
kwleland / gist:4e788b9a091423118d21
Last active August 29, 2015 14:20
Garbage Collector Hang Repro
Thread.new do
while true
sleep 10
puts "heartbeat"
end
end
while true
ar = []
100.times do
Script started on Tue 07 Apr 2015 10:23:47 AM EDT
[root@app0 ~]# gdb -p 22482
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-75.el6)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
@kwleland
kwleland / bench_element_assignment.rb
Created December 16, 2013 15:16
String#[]= benchmark
require 'benchmark'
require 'benchmark/ips'
Benchmark.ips do |x|
s = "abcdefghijk"
last_index = s.length - 1
middle_index = last_index/2
x.report("element assignment at beginning") do |times|
@kwleland
kwleland / word_anagrams.rb
Created December 13, 2013 16:38
same as bm_word_anagrams.rb without the benchmark
# Word anagrams (with duplicates).
# Submitted by Giovanni Intini <intinig@gmail.com>
class String
def swap(i)
tmp = self[0,1]
self[0] = self[i]
self[i] = tmp
self
end
@kwleland
kwleland / gist:7946415
Created December 13, 2013 15:57
profile of bm_word_anagrams.rb
Thread 1: total running time: 191.491809676s
% cumulative self self total
time seconds seconds calls ms/call ms/call name
------------------------------------------------------------
8.36 23.56 16.02 4150098 0.00 0.01 String#[]
7.43 27.81 14.24 2903040 0.00 0.01 String#replace
7.32 35.12 14.03 1247058 0.01 0.03 String#[]=
6.25 63.45 11.97 2903040 0.00 0.02 String#+
5.84 26.53 11.19 884179 0.01 0.03 Array::recursively_flatten<1796> {}
@kwleland
kwleland / bench_scan.rb
Created December 9, 2013 21:14
Rubinius String#scan benchmark
require 'benchmark'
require 'benchmark/ips'
long_text = File.new('holmes.txt').read.downcase
#holmes.txt @ http://norvig.com/holmes.txt
medium_text = long_text.slice(0,1000)
short_text = long_text.slice(0,100)
Benchmark.ips do |x|
x.report "string scan (long length)" do |times|
@kwleland
kwleland / gist:7771050
Created December 3, 2013 15:24
rubinius debugger backtrace
admin2:ruby kwleland$ ruby -Xdebug x8.rb
An exception occurred running the debugger:
no such file to load -- rubinius/compiler/iseq (LoadError)
Backtrace:
Rubinius::CodeLoader#load_error at kernel/common/code_loader.rb:440
Rubinius::CodeLoader#resolve_require_path at kernel/common/code_loader.rb:423
{ } in Rubinius::CodeLoader#require at kernel/common/code_loader.rb:103