Skip to content

Instantly share code, notes, and snippets.

@the8472
the8472 / ci.rb
Created August 28, 2014 17:48
Continuous building for firefox addons
#!/usr/bin/ruby
require "rubygems"
gem "rb-inotify"
require "rb-inotify"
notifier = INotify::Notifier.new
event_handler = proc do
puts "change detected, running CI"
@the8472
the8472 / testcase.rb
Created October 25, 2013 13:48
squeel + globalize breakage
#!/usr/bin/env ruby
gem 'activerecord', "~> 3.2.0"
gem "squeel"
gem "globalize", "~> 3.0.0"
gem 'sqlite3'
require "active_record"
require "squeel"
#require "globalize"
gem 'rails', "~> 3.2"
gem 'squeel', "~> 1.1"
gem 'sqlite3'
require "active_record"
require "squeel"
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
class A < ActiveRecord::Base
require "dalli"
module ActiveSupport::Cache
# unlike the "official" dalli store this subclasses the abstract Store class which handles nil values properly
# also implement the local cache strategy to avoid network hits
class SimpleDalliStore < Store
def initialize(*addresses)
opts = addresses.extract_options!
Back traces
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
| Name | Time (ms) |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
| +---org.jruby.util.ByteList.lookup(String) | 60 100 % |
| |
@the8472
the8472 / gist:4446959
Created January 3, 2013 20:32
stamped ivar updater for jruby
diff --git a/src/org/jruby/RubyBasicObject.java b/src/org/jruby/RubyBasicObject.java
index 2bb34e8..6de4bef 100644
--- a/src/org/jruby/RubyBasicObject.java
+++ b/src/org/jruby/RubyBasicObject.java
@@ -38,6 +38,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
@the8472
the8472 / gist:4426366
Created January 1, 2013 10:20
volatile/non-volatile/unsafe read test
import java.lang.reflect.Field;
import java.security.SecureRandom;
import sun.misc.Unsafe;
public class Test2 {
static final Unsafe unsafe;
static final long offsetA;
static final long offsetB;
@the8472
the8472 / assembly test1()
Created December 31, 2012 16:02
opto test volatile field access
Compiled method (c2) 593 8 Test2::test1 (46 bytes)
total in heap [0x029af8c8,0x029b0184] = 2236
relocation [0x029af99c,0x029af9b8] = 28
main code [0x029af9c0,0x029afd00] = 832
stub code [0x029afd00,0x029afd10] = 16
oops [0x029afd10,0x029afd14] = 4
metadata [0x029afd14,0x029afd18] = 4
scopes data [0x029afd18,0x029afddc] = 196
scopes pcs [0x029afddc,0x029b013c] = 864
dependencies [0x029b013c,0x029b0140] = 4
@the8472
the8472 / minimal testing up
Created December 12, 2012 16:28
Rails startup performance tuning with jruby. Note that those settings are *not* for optimal steady state operation.
### ruby 1.9.3 + railsexpress patches + GC tuning + -march=native -O3
time ruby script/rails r 'Post.count'
real 0m1.008s
user 0m0.820s
sys 0m0.180s
### jruby 1.7.2-dev 2012-12-12 + java 64bit 1.8.0-ea-b67 hotspot 25.0-b11
module Mhmr::DescendantsTracker
def descendants_and_self
[self].concat self.descendants
end
end
ActiveSupport::DescendantsTracker.send(:include,Mhmr::DescendantsTracker)
jruby: