Skip to content

Instantly share code, notes, and snippets.

©️
   ​

Aaron Patterson tenderlove

©️
   ​
Block or report user

Report or block tenderlove

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View memory_stuff.rb
# How to measure the size of a method's iseq
require 'objspace'
small_body = (["bar"] * 10).join(" + ")
big_body = (["bar"] * 10_000).join(" + ")
eval "def small(bar); #{small_body}; end"
eval "def big(bar); #{big_body}; end"
View header.h
#ifdef __GNUC__
# pragma GCC system_header
#endif
View gc-perf.md

Benchmarks for GC Compactor

GC benchmarks for trunk vs gc-compact seem to be about the same:

$ make benchmark ITEM=gc
./revision.h unchanged
/Users/aaron/.rbenv/shims/ruby --disable=gems -rrubygems -I./benchmark/lib ./benchmark/benchmark-driver/exe/benchmark-driver \
	            --executables="compare-ruby::/Users/aaron/.rbenv/shims/ruby --disable=gems -I.ext/common --disable-gem" \
	            --executables="built-ruby::./miniruby -I./lib -I. -I.ext/common  -r./prelude --disable-gem" \
View heapviz.rb
require 'fiddle'
color_iter = DATA.readlines.map(&:chomp).map { |i|
i = i.to_i(16)
[(i >> 16) & 0xFF, (i >> 8) & 0xFF, i & 0xFF, 255]
}.each
SIZEOF_HEAP_PAGE_HEADER_STRUCT = Fiddle::SIZEOF_VOIDP
SIZEOF_RVALUE = 40
View thing.rb
begin
Integer("foo", exception: false)
def parse_int string, default
Integer(string, exception: false) || default
end
rescue TypeError
def parse_int string, default
Integer(string)
rescue
View thing.patch
From 8f74c91274a7e1072685aded111e89d55ced0f96 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <aaron.patterson@gmail.com>
Date: Sun, 21 Oct 2018 16:12:16 -0700
Subject: [PATCH] Collapse putobject, putobject, newarray
This collapses:
```== disasm: #<ISeq:bar@bench.rb:3 (3,0)-(5,3)> (catch: FALSE)
0000 putobject "a" ( 4)[LiCa]
0002 putobject "b"
View thing.diff
From 8f74c91274a7e1072685aded111e89d55ced0f96 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <aaron.patterson@gmail.com>
Date: Sun, 21 Oct 2018 16:12:16 -0700
Subject: [PATCH] Collapse putobject, putobject, newarray
This collapses:
```== disasm: #<ISeq:bar@bench.rb:3 (3,0)-(5,3)> (catch: FALSE)
0000 putobject "a" ( 4)[LiCa]
0002 putobject "b"
View duparray.diff
From 8f74c91274a7e1072685aded111e89d55ced0f96 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <aaron.patterson@gmail.com>
Date: Sun, 21 Oct 2018 16:12:16 -0700
Subject: [PATCH] Collapse putobject, putobject, newarray
This collapses:
```== disasm: #<ISeq:bar@bench.rb:3 (3,0)-(5,3)> (catch: FALSE)
0000 putobject "a" ( 4)[LiCa]
0002 putobject "b"
View dead_heap.rb
# extract dead objects from the heap
require 'json'
require 'set'
class Slot
attr_reader :info, :address_to_slot
def initialize info, address_to_slot
@info = info
View grpc_client.rb
require 'ds9'
require 'socket'
require 'uri'
require 'google/protobuf'
require 'io/wait'
require 'helloworld_pb'
class MySession < DS9::Client
def initialize sock
@sock = sock
You can’t perform that action at this time.