Skip to content

Instantly share code, notes, and snippets.

View tenderlove's full-sized avatar
©️
 ​[object Object] :trollface:

Aaron Patterson tenderlove

©️
 ​[object Object] :trollface:
View GitHub Profile
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
require "ast"
class Superduper
class EnumerableAST
include Enumerable
def initialize ast
@ast = ast
end
# 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"
#ifdef __GNUC__
# pragma GCC system_header
#endif

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" \
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
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
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"
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"
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"