Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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;
Back traces
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
| Name | Time (ms) |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+
| +---org.jruby.util.ByteList.lookup(String) | 60 100 % |
| |
@the8472
the8472 / replace-channel.js
Created December 17, 2015 08:41
replacing a channel instead of calling `redirect()`
"use strict";
const { Cc, Ci, Cr } = require('chrome');
const ioservice = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
const events = require("sdk/system/events");
const listener = function(event) {
let {subject, type, data} = event;
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!
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
@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"
### remote RPCs
Method REQ | RSP Errors
PING 3832900629 | 3832944684 0
FIND_NODE 15033719926 | 15028735737 0
GET_PEERS 30474134400 | 30482866044 0
ANNOUNCE_PEER 3739103559 | 3541140713 198040816
GET 661604 | 661600 0
PUT 76383 | 61719 14664
UNKNOWN 120320970 | 120321404 62307537
[2016-06-05T23:09:42.561Z][Verbose] PeerLookupTask 1404 target:DFE43711 5F5127E1 D00D6C0C 1CA8B7B0 60588414 todo:120 SENT:34 RECEIVED:20 STALLED:3 FAILED:11 SENT_SINCE_RECEIVE:0 activeOnly:0 unanswered:3 srv: 794A1D46 2A62604D F2677C23 314A900A 44FCF0CE finished time to finish:PT5.267S name:null
Task 1404 done SENT:34 RECEIVED:20 STALLED:3 FAILED:11 SENT_SINCE_RECEIVE:0 activeOnly:0 unanswered:3 closestset: 8 tailMod:1 headMod:4 head:23 tail:18
DFE43711 5F5127E1 D00D6C0C 1CA8B7B0 60588414
DFE43677 6349C0FB 845264BC 8AD5974A 84C0227E 00000166 3C18E71A 545F08B0 967D20FA E498A66A 1.2190097033989033E41 src:3
DFE434DE B3124DC8 43BB8BA6 1F035A7D 093825B7 000003CF EC436A29 93B6E7AA 03ABEDCD 6960A1A3 3.3208935559203926E41 src:1
DFE432D1 F754A666 114BFB4D C083E28A 809BBC1C 000005C0 A8058187 C1469741 DC2B553A E0C33808 5.01118982999584E41 src:6
DFE43E70 A4CFEEE1 8AB5AC91 FA265DB5 280F84C5 00000961 FB9EC900 5AB8C09D E68EEA05 485700D1 8.173524236638113E41 src:6
DFE4253C 870C3E99 245E0D1C 06B747DE B3124DA6 0000122D D