Skip to content

Instantly share code, notes, and snippets.

View KJTsanaktsidis's full-sized avatar

KJ Tsanaktsidis KJTsanaktsidis

View GitHub Profile
ruby 3.3.0dev (2023-03-18T02:16:48Z ktsanaktsidis/yjit.. d09365c3b3) [aarch64-linux]
-------------- ----------- ---------- --------- ---------- ----------- ------------
bench interp (ms) stddev (%) yjit (ms) stddev (%) interp/yjit yjit 1st itr
activerecord 205.7 0.8 98.5 1.7 2.09 0.51
hexapdf 4967.0 0.8 2458.2 2.4 2.02 1.13
liquid-c 89.4 1.5 63.1 4.2 1.42 0.26
liquid-render 299.2 0.8 135.0 3.6 2.22 0.58
mail 208.0 0.5 105.5 4.8 1.97 0.29
psych-load 4492.7 0.1 1922.0 0.3 2.34 2.21
railsbench 2793.0 0.3 1556.0 1.5 1.80 0.70
ruby 3.3.0dev (2023-03-14T07:07:59Z master ac65ce16e9) [aarch64-linux]
-------------- ----------- ---------- --------- ---------- ----------- ------------
bench interp (ms) stddev (%) yjit (ms) stddev (%) interp/yjit yjit 1st itr
activerecord 206.9 0.9 97.5 1.3 2.12 0.62
hexapdf 4940.6 1.0 2415.3 2.2 2.05 1.20
liquid-c 88.9 2.0 61.9 3.4 1.44 0.30
liquid-render 300.5 1.7 135.3 3.1 2.22 0.64
mail 209.0 0.6 104.6 3.7 2.00 0.32
psych-load 4474.7 0.3 1887.1 0.1 2.37 2.24
railsbench 2794.2 0.5 1544.4 1.5 1.81 0.74
RUBY_T_MASK = 0x1f
RUBY_T_STRING = 0x05
RUBY_T_ARRAY = 0x07
RSTRING_EMBED_LEN_SHIFT = 0x0e
RSTRING_EMBED_LEN_MASK = 0x7c000
RSTRING_NOEMBED = 0x2000
RARRAY_EMBED_FLAG = 0x2000
RARRAY_EMBED_LEN_SHIFT = 0x0f
RARRAY_EMBED_LEN_MASK = 0x18000
RUBY_ID_SCOPE_SHIFT = 0x4
#include <errno.h>
#include <sched.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
int main_parent(pid_t child_pid) {
@KJTsanaktsidis
KJTsanaktsidis / gist:80a7005cd0784f73b83ab121b1b82cc9
Created January 24, 2023 11:47
Renaming an anonymous class in Ruby...
kj@kj-thinkpad ~ % cat rename.rb
#!/usr/bin/env ruby
require 'fiddle'
libruby = Fiddle::Handle.new
rb_set_class_path_string = Fiddle::Function.new(
libruby['rb_set_class_path_string'],
[
Fiddle::TYPE_UINTPTR_T,
@KJTsanaktsidis
KJTsanaktsidis / curl_parallel.c
Created November 21, 2022 06:57
glibc dns timeout reproduction
#include <curl/curl.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define NUM_THREADS 20
static pthread_mutex_t outlock = PTHREAD_MUTEX_INITIALIZER;
@KJTsanaktsidis
KJTsanaktsidis / riak.lua
Created November 17, 2022 09:47
Wireshark protocol dissector for Riak
-- Riak protocol decoder
-- Based on copypasta from https://wiki.wireshark.org/Protobuf.md
-- To use,
-- * Plase in ~/.local/lib/wireshark/plugins/riak.lua
-- * Check out https://github.com/protocolbuffers/protobuf somewhere
-- * Check out https://github.com/basho/riak_pb somewhere
-- * In the "ProtoBuf" protocol preferences, add protobuf/src and riak_pb/src
-- to the search paths. Make sure "load all" is checked for riak_pb, but NOT
-- for protobuf.
-- * right click a stream -> decode as -> "RIAK_PROTO"
With memocache:
kj@kj-thinkpad ruby_memprofiler_pprof % ruby script/benchmark.rb
user system total real
no profiling (1) 15.844936 0.469273 16.314209 ( 16.337021)
no profiling (2) 14.966771 0.034934 15.001705 ( 15.020942)
with profiling (1%, no flush) 15.971306 0.477258 16.448564 ( 16.471195)
with reporting (1%, with flush) 17.402173 0.029948 17.432121 ( 17.454925)
with profiling (10%, no flush) 23.168302 0.289576 23.457878 ( 23.487329)
with reporting (10%, with flush) 48.194583 0.042943 48.237526 ( 48.290087)
@KJTsanaktsidis
KJTsanaktsidis / gist:ac4d7bf85bceb171e39f5c5534771995
Created June 13, 2022 06:42
Apparently it's slow because of marking everything?
Samples: 8K of event 'cycles', Event count (approx.): 367381525322, DSO: ruby_memprofiler_pprof_ext.so
Children Self Comm Symbol
+ 60.45% 0.00% ruby [.] collector_cdata_gc_mark ▒
+ 60.34% 0.03% ruby [.] collector_gc_mark_each_heap_sample ▒
+ 60.30% 0.26% ruby [.] mpp_sample_gc_mark ▒
+ 0.74% 0.00% ruby [.] collector_tphook_newobj ▒
0.04% 0.00% ruby [.] collector_tphook_freeobj ▒
0.02% 0.01% ruby [.] mpp_rb_gc_disable_no_rest ▒
0.01% 0.01% ruby [.] backtracie_bt_gc_mark_moveable@plt
kj@kj-thinkpad ruby_memprofiler_pprof % ruby script/benchmark.rb
user system total real
no profiling (1) 15.867480 0.473907 16.341387 ( 16.382863)
no profiling (2) 14.955051 0.031678 14.986729 ( 15.025699)
with profiling (1%, no flush) 22.981310 0.484232 23.465542 ( 23.501221)
with reporting (1%, with flush) 24.261126 0.057177 24.318303 ( 24.353663)
with profiling (10%, no flush) 109.202573 0.291814 109.494387 (109.596998)
with reporting (10%, with flush) 154.720902 0.060936 154.781838 (154.920858)