Skip to content
View this_is_why_socket_stdlib_is_fucking_terrible.rb
require 'socket'
Socket.gethostbyname('localhost') # => ["localhost.localdomain", ["localhost", "x1carbon", "localhost", "x1carbon"], 10, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", "\x7F\x00\x00\x01"]
TCPSocket.gethostbyname('localhost') # => ["localhost.localdomain", ["localhost", "x1carbon", "localhost", "x1carbon"], 10, "::1", "127.0.0.1"]
View results.txt
Numbers indicate the amount of iterations in 5 seconds.
The C example was compiled using:
clang -Wall -Wextra -pedantic -O2 test.c -o test
Results:
C: 2272688181
LuaJIT 170557787 => ~13x slower
View webscale.rb
Calculating -------------------------------------
Array#[] 201.052k i/100ms
Array#at 194.228k i/100ms
-------------------------------------------------
Array#[] 11.090M (± 2.2%) i/s - 55.490M
Array#at 10.003M (± 1.3%) i/s - 50.111M
Comparison:
Array#[]: 11089538.6 i/s
Array#at: 10002944.7 i/s - 1.11x slower
View recvmsg.rb
require 'socket'
server = Socket.new(:INET, :DGRAM)
client = Socket.new(:INET, :DGRAM)
server.bind(Socket.sockaddr_in(0, '127.0.0.1'))
client.connect(Socket.sockaddr_in(server.connect_address.ip_port, '127.0.0.1'))
client.write('hello world how are you doing')
View external-monitor.fish
function external-monitor -d 'Enable/disable external monitor'
if [ "$argv[1]" = "on" ]
echo 'Starting bumblebeed...'
sudo systemctl start bumblebeed
echo 'Enabling discrete GPU...'
echo ON | sudo tee /proc/acpi/bbswitch
View gist:a7ff06705b5816106f88
Starting program: /home/yorickpeterse/Private/Projects/ruby/rubinius/bin/rbx ./bin/mspec spec/ruby/core/io/select_spec.rb
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff7f8d700 (LWP 7548)]
[New Thread 0x7ffff1086700 (LWP 7549)]
[New Thread 0x7ffff0c85700 (LWP 7550)]
[New Thread 0x7fffe3fff700 (LWP 7551)]
[New Thread 0x7ffff0484700 (LWP 7552)]
[Thread 0x7fffe3fff700 (LWP 7551) exited]
[Thread 0x7ffff0484700 (LWP 7552) exited]
View gist:4c89539c3eb509469b69
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /home/yorickpeterse/.rubies/ruby-2.2.2/bin/ruby /tmp/sequel_test.rb
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7ffff7ff7700 (LWP 21397)]
Preparing...
Starting threads...
[New Thread 0x7ffff3a9a700 (LWP 21399)]
[New Thread 0x7ffff3898700 (LWP 21400)]
View gist:8d3cd78488cfed4e134a
/home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:165: [BUG] Segmentation fault at 0x00000000000014
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0020 p:0011 s:0078 e:000077 BLOCK /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:165
c:0019 p:0006 s:0076 e:000075 METHOD /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/core.rb:312
c:0018 p:0013 s:0073 e:000072 METHOD /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:165
c:0017 p:0009 s:0069 e:000068 METHOD /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:193
c:0016 p:0011 s:0064 e:000063 BLOCK /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:98
c:0015 p:0008 s:0060 e:000059 BLOCK /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/dat
View sequel_boom.rb
require 'sequel'
require 'securerandom'
db_host = 'localhost'
db_name = 'test'
db_user = 'root'
db_options = {test: true, max_connections: 10, encoding: 'UTF-8'}
if defined?(JRuby)
View gist:8fb4f6207d2463718df6
Preparing...
Starting threads...
/home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:165: [BUG] Segmentation fault at 0x00000000000000
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0013 p:0011 s:0051 e:000050 BLOCK /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:165
c:0012 p:0006 s:0049 e:000048 METHOD /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/core.rb:312
c:0011 p:0013 s:0046 e:000045 METHOD /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:165
c:0010 p:0009 s:0042 e:000041 METHOD /home/yorickpeterse/.gem/ruby/2.2.2/gems/sequel-4.26.0/lib/sequel/database/transactions.rb:193
Something went wrong with that request. Please try again.