Skip to content

Instantly share code, notes, and snippets.

View casperisfine's full-sized avatar

Jean byroot Boussier casperisfine

View GitHub Profile
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "sqlite3"
gem "enumerable-statistics"
end
require "benchmark"
(gdb) thread apply all bt
Thread 60 (Thread 0x7fd3289ff700 (LWP 64)):
#0 futex_abstimed_wait_cancelable (private=<optimized out>, abstime=0x7fd3289fd590, clockid=<optimized out>, expected=0, futex_word=0x7fd3289fd5c8) at ../sysdeps/nptl/futex-internal.h:320
#1 __pthread_cond_wait_common (abstime=0x7fd3289fd590, clockid=<optimized out>, mutex=0x55759e806e20 <thread_cache_lock>, cond=0x7fd3289fd5a0) at pthread_cond_wait.c:520
#2 __pthread_cond_timedwait (cond=cond@entry=0x7fd3289fd5a0, mutex=mutex@entry=0x55759e806e20 <thread_cache_lock>, abstime=abstime@entry=0x7fd3289fd590) at pthread_cond_wait.c:665
#3 0x000055759e40afe8 in native_cond_timedwait (abs=<synthetic pointer>, mutex=0x55759e806e20 <thread_cache_lock>, cond=0x7fd3289fd5a0) at thread_pthread.c:685
#4 register_cached_thread_and_wait (altstack=0x7fd33f001280) at thread_pthread.c:1237
#5 thread_start_func_1 (th_ptr=<optimized out>) at thread_pthread.c:1182
#6 0x00007fd347d31609 in start_thread (arg=<optimized out>) at pthread_create.c:477
class UnserializableError < StandardError
def initialize(...)
super
@oops = -> () { }
end
end
NormalError = Class.new(StandardError)
error = begin
def test(name)
module_eval("private; def #{name}; end")
end
def test2(name, private: nil)
module_eval("private; def #{name}; end")
end
module Foo
puts '-'* 40
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
require 'objspace'
require 'json'
class Foo
class_eval <<~RUBY
def initialize
#{21.times.map { |i| "@attr_#{i} = #{i}" }.join("\n")}
end
RUBY
#!/bin/sh
set -eu
AGGRESSIVE=0
PARAMS=""
while [ "$#" -gt 0 ]; do
case "$1" in
--aggressive)

Plan for redis-rb 5.0

A large part of redis-rb maintenance cost comes from having to implement each command Redis add. A year after Redis 6.2 release, we're still missing a large part of the newly added commands, and tengentially commands added by Redis modules are hard to use.

This comes down to the RESP2 protocol that requires to know how to parse each command output.

However Redis 6.0 introduced the RESP3 protocol, which is properly typed allowing clients to not know anything about the commands they are sending, which means a drastically simpler and smaller implementation that don't need keeping up with commands added upstream.

/tmp/bundle/ruby/3.1.0/bundler/gems/mysql2-8193dc412c6a/lib/mysql2/client.rb:148: [BUG] Segmentation fault at 0x000000000015613a
ruby 3.1.0p0 (2021-12-25 revision fb4df44d16) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0060 p:---- s:0354 e:000353 CFUNC :_query
c:0059 p:0012 s:0348 e:000347 BLOCK /tmp/bundle/ruby/3.1.0/bundler/gems/mysql2-8193dc412c6a/lib/mysql2/client.rb:148 [FINISH]
c:0058 p:---- s:0345 e:000344 CFUNC :handle_interrupt
c:0057 p:0036 s:0340 e:000339 METHOD /tmp/bundle/ruby/3.1.0/bundler/gems/mysql2-8193dc412c6a/lib/mysql2/client.rb:147
c:0056 p:0008 s:0334 e:000333 METHOD /app/lib/patches/01_mysql_monitoring.rb:6
c:0055 p:0007 s:0328 e:000327 BLOCK /tmp/bundle/ruby/3.1.0/gems/semian-0.11.8/lib/semian/mysql2.rb:82
require "set"
require "objspace"
module DeepMemsize
class << self
def memsize_of(object, seen = Set.new.compare_by_identity)
return 0 unless seen.add?(object)
size = ObjectSpace.memsize_of(object)
object.instance_variables.each { |v| size += memsize_of(object.instance_variable_get(v), seen) }