Skip to content

Instantly share code, notes, and snippets.

View brixen's full-sized avatar

Brian Shirai brixen

View GitHub Profile
require 'benchmark/ips'
class A
# def fib(n)
# return n if n < 2
# fib(n-2) + fib(n-1)
# end
dynamic_method :fib do |g|
@brixen
brixen / result.txt
Created June 15, 2019 20:11
Illustration of Rubinius tagged nil that enables tracing where a nil value originated
rbx tagged_nil.rb
main # Rubinius::Loader at core/loader.rb:852 (+90)
script # Rubinius::Loader at core/loader.rb:667 (+343)
load_script # Rubinius::CodeLoader at
core/code_loader.rb:280 (+60)
load # Rubinius::CodeLoader::Source(Rubinius::CodeLoader::Script) at
core/code_loader.rb:119 (+81)
run_script # Rubinius::CodeLoader::Source(Rubinius::CodeLoader::Script) at
core/code_loader.rb:132 (+21)
__script__ # Object at tagged_nil.rb:50 (+153)
* thread #3, name = 'ruby.107'
* frame #0: 0x00007fff78c7db0e libsystem_kernel.dylib`__psynch_rw_wrlock + 10
frame #1: 0x00007fff78d39dd0 libsystem_pthread.dylib`_pthread_rwlock_lock_wait + 75
frame #2: 0x00007fff78d37bc6 libsystem_pthread.dylib`_pthread_rwlock_lock_slow + 547
frame #3: 0x00007fff78bdff7e libsystem_c.dylib`tzsetwall_basic + 98
frame #4: 0x00007fff78be1ed5 libsystem_c.dylib`localtime_r + 41
frame #5: 0x000000010ccaf041 rbx`rubinius::logger::FileLogger::write_log(char const*, char const*, int) [inlined] rubinius::logger::Logger::timestamp(this=<unavailable>) at logger.cpp:271:7 [opt]
frame #6: 0x000000010ccaf02c rbx`rubinius::logger::FileLogger::write_log(this=0x00007fe051cbfe00, level="<Info>", message="collector: worker thread starting\n", size=34) at logger.cpp:615 [opt]
frame #7: 0x000000010ccad490 rbx`rubinius::logger::info(message=<unavailable>, args=<unavailable>) at logger.cpp:239:18 [opt]
frame #8: 0x000000010ccace30 rbx`rubinius::logger::info(message=
@brixen
brixen / stacktrace.txt
Created May 4, 2019 17:11
Rubinius debug log of nokogiri test run
May 4 09:40:31 [51665] <Debug> Backtrace for Thread: ruby.main
May 4 09:40:31 [51665] <Debug> 0 rbx 0x000000010049a0d9 rubinius::ThreadNexus::check_stack(rubinius::State*, rubinius::VM*) + 57
May 4 09:40:31 [51665] <Debug> 1 rbx 0x00000001004d872b rubinius::ThreadNexus::check_stop(rubinius::State*, rubinius::VM*, std::__1::function<void ()>) + 75
May 4 09:40:31 [51665] <Debug> 2 rbx 0x00000001004d85c8 rubinius::VM::checkpoint(rubinius::State*) + 88
May 4 09:40:31 [51665] <Debug> 3 rbx 0x0000000100411831 rubinius::instructions::send_method(rubinius::State*, rubinius::CallFrame*, long) + 96
May 4 09:40:31 [51665] <Debug> 4 rbx 0x00000001004117a9 rubinius::interpreter::send_method(rubinius::State*, rubinius::CallFrame*, long const*) + 33
May 4 09:40:31 [51665] <Debug> 5 rbx 0x000000010040d2d0 rubinius::In
@brixen
brixen / backtrace.txt
Created May 4, 2019 05:25
Rubinius thread backtrace when GC runs during nokogiri tests
May 3 21:54:47 [50940] <Debug> Backtrace for Thread: ruby.main
May 3 21:54:47 [50940] <Debug> 0 rbx 0x0000000105cb70d9 rubinius::ThreadNexus::check_stack(rubinius::State*, rubinius::VM*) + 57
May 3 21:54:47 [50940] <Debug> 1 rbx 0x0000000105cf572b rubinius::ThreadNexus::check_stop(rubinius::State*, rubinius::VM*, std::__1::function<void ()>) + 75
May 3 21:54:47 [50940] <Debug> 2 rbx 0x0000000105cf55c8 rubinius::VM::checkpoint(rubinius::State*) + 88
May 3 21:54:47 [50940] <Debug> 3 rbx 0x0000000105c2e91b rubinius::instructions::send_stack(rubinius::State*, rubinius::CallFrame*, long, long) + 116
May 3 21:54:47 [50940] <Debug> 4 rbx 0x0000000105c2e87f rubinius::interpreter::send_stack(rubinius::State*, rubinius::CallFrame*, long const*) + 38
May 3 21:54:47 [50940] <Debug> 5 rbx 0x0000000105c2a2d0 rubiniu
@brixen
brixen / debug_log.txt
Created April 27, 2019 18:48
Rubinius debug log of running `bundle install`
This file has been truncated, but you can view the full file.
Apr 27 11:39:49 [19768] command line: rbx /source/rubinius/rubinius/gems/bin/bundle install
Apr 27 11:39:49 [19768] config: log.level=debug
Apr 27 11:39:49 [19768] thread: run: ruby.main, 198780, 0x9733000
Apr 27 11:39:49 [19768] node: info: Shirai-MacBook.local Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64
Apr 27 11:39:49 [19768] process: info: brianshirai rbx 19768 3.107.c2 2.3.1 2019-04-27 65fba7aa 7.0.1 JIT disabled
Apr 27 11:39:49 [19768] process: boot stats: fields 602us main thread: 42us memory: 10688us ontology: 5880us platform: 2309us
Apr 27 11:39:49 [19768] codedb: loading: /source/rubinius/rubinius/codedb/cache
Apr 27 11:39:49 [19768] <Debug> codedb: load: core/alpha.rb, __script__
Apr 27 11:39:49 [19768] <Debug> codedb: load: core/alpha.rb, VM
Apr 27 11:39:49 [19768] <Debug> codedb: load: core/alpha.rb, Object
@brixen
brixen / stacktrace.txt
Created April 27, 2019 05:23
Rubinius stacktrace log before GC
Apr 26 22:21:56 [2724] <Debug> Backtrace for thread: ruby.main
Apr 26 22:21:56 [2724] <Debug> 0 rbx 0x00000001040d4c99 rubinius::ThreadNexus::check_stack(rubinius::State*, rubinius::VM*) + 57
Apr 26 22:21:56 [2724] <Debug> 1 rbx 0x000000010410edcb rubinius::ThreadNexus::check_stop(rubinius::State*, rubinius::VM*, std::__1::function<void ()>) + 75
Apr 26 22:21:56 [2724] <Debug> 2 rbx 0x000000010410ec68 rubinius::VM::checkpoint(rubinius::State*) + 88
Apr 26 22:21:56 [2724] <Debug> 3 rbx 0x000000010404cffb rubinius::instructions::send_stack(rubinius::State*, rubinius::CallFrame*, long, long) + 116
Apr 26 22:21:56 [2724] <Debug> 4 rbx 0x000000010404cf5f rubinius::interpreter::send_stack(rubinius::State*, rubinius::CallFrame*, long const*) + 38
Apr 26 22:21:56 [2724] <Debug> 5 rbx 0x00000001040489b0 rubinius::Inte
@brixen
brixen / rbx.log
Created April 25, 2019 04:52
Rubinius log of Nokogiri spec run to SEGV
This file has been truncated, but you can view the full file.
Apr 24 21:39:36 [55486] command line: rbx /source/rubinius/rubinius/gems/bin/bundle exec rake test
Apr 24 21:39:36 [55486] config: log.level=debug
Apr 24 21:39:36 [55486] thread: run: ruby.main, 786314, 0x1a9c000
Apr 24 21:39:36 [55486] node: info: Shirai-MacBook.local Darwin Kernel Version 18.5.0: Mon Mar 11 20:40:32 PDT 2019; root:xnu-4903.251.3~3/RELEASE_X86_64
Apr 24 21:39:36 [55486] process: info: brianshirai rbx 55486 3.107.c1 2.3.1 2019-01-01 fcb05ca3 7.0.1 JIT disabled
Apr 24 21:39:36 [55486] process: boot stats: fields 1823us main thread: 57us memory: 13018us ontology: 15735us platform: 3768us
Apr 24 21:39:37 [55486] codedb: loading: /source/rubinius/rubinius/codedb/cache
Apr 24 21:39:37 [55486] <Debug> codedb: load: core/alpha.rb, __script__
Apr 24 21:39:37 [55486] <Debug> codedb: load: core/alpha.rb, VM
Apr 24 21:39:37 [55486] <Debug> codedb: load: core/alpha.rb, Object
@brixen
brixen / stacktrace.txt
Created April 24, 2019 05:59
Stack trace when pausing for GC
Apr 23 22:52:21 [54767] <Debug> Backtrace for thread: ruby.main
Apr 23 22:52:21 [54767] <Debug> 0 rbx 0x00000001076b9db7 _ZN8rubinius11ThreadNexus11check_stackEPNS_5StateEPNS_2VME + 55
Apr 23 22:52:21 [54767] <Debug> 1 rbx 0x00000001076f3deb _ZN8rubinius11ThreadNexus10check_stopEPNS_5StateEPNS_2VMENSt3__18functionIFvvEEE + 75
Apr 23 22:52:21 [54767] <Debug> 2 rbx 0x00000001076f3c88 _ZN8rubinius2VM10checkpointEPNS_5StateE + 88
Apr 23 22:52:21 [54767] <Debug> 3 rbx 0x000000010763211b _ZN8rubinius12instructions10send_stackEPNS_5StateEPNS_9CallFrameEll + 116
Apr 23 22:52:21 [54767] <Debug> 4 rbx 0x000000010763207f _ZN8rubinius11interpreter10send_stackEPNS_5StateEPNS_9CallFrameEPKl + 38
Apr 23 22:52:21 [54767] <Debug> 5 rbx 0x000000010762dad0 _ZN8rubinius11Interpreter7executeEPNS_5StateEPNS_11MachineCodeE + 64
Apr
irb(main):001:0> module M
irb(main):002:1> def mm; puts "M.mm"; end
irb(main):003:1> def m; puts "#{self.class}#m"; end
irb(main):004:1> end
=> :m
irb(main):005:0> class A
irb(main):006:1> include M
irb(main):007:1> extend M
irb(main):008:1> end
=> A