Skip to content

Instantly share code, notes, and snippets.

View byroot's full-sized avatar

Jean Boussier byroot

View GitHub Profile
@byroot
byroot / idea.md
Created January 28, 2024 23:03
Relation refactoring idea
  • Extending -> record module and method_missing + bind_call (confirm that bind call doesn't allocate metaclass).
  • Single generic Relation class. Stop dynamic method generation.
# frozen_string_literal: true
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'benchmark-ips'
end
require 'benchmark/ips'
RubyVM::InstructionSequence.compile_option = { peephole_optimization: false }
class RubyVM::InstructionSequence
def self.load_iseq(path)
RubyVM::InstructionSequence.compile_file(path)
end
end
# Can be enabled with RUBYOPT="-r /path/to/disable_opt.rb"
@byroot
byroot / results.txt
Last active September 5, 2021 12:52
Impact of stack size on exceptions performance
$ ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin17]
$ ruby yield-vs-block.rb
Nested yield stack size: 402
Forward block stack size: 202
Warming up --------------------------------------
baseline 82.138k i/100ms
nested-yield 16.030k i/100ms
forward-block 28.945k i/100ms
Calculating -------------------------------------
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
source "https://rubygems.org"
gem "activerecord", "~> 5.2"
@byroot
byroot / fix-wifi.sh
Last active September 30, 2022 21:06
#!/bin/bash
# See: http://osxdaily.com/2015/10/16/fix-wi-fi-problems-mac-os-x-el-capitan/
sudo rm -f /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist
com.apple.network.identification.plist
sudo rm -f /Library/Preferences/SystemConfiguration/com.apple.wifi.message-tracer.plist
sudo rm -f /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist
sudo rm -f /Library/Preferences/SystemConfiguration/preferences.plist
sudo reboot
byroot@raplh:byroot:$ MISSING_KEY=1 SSHKIT_VERSION=1.10.0 ruby repro-sshkit.rb
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Resolving dependencies...
Using net-ssh 3.2.0
Using bundler 1.12.3
Using net-scp 1.2.1
Using sshkit 1.10.0
INFO [a3263e4e] Running /usr/bin/env echo foo as git@github.com
-- Content of known_hosts file:
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
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
require 'benchmark/ips'
require 'active_support/cache'
require 'memcached'
require 'active_support/cache/memcached_store'
require 'active_support/cache/dalli_store'
$dalli = ActiveSupport::Cache::DalliStore.new('127.0.0.1:11211')
$memcached = ActiveSupport::Cache::MemcachedStore.new('127.0.0.1:11211')
KEY = 'somekey'
Calculating -------------------------------------
thread-safe 72.674k i/100ms
-------------------------------------------------
thread-safe 2.128M (± 5.8%) i/s - 10.610M
Calculating -------------------------------------
thread-unsafe 109.385k i/100ms
-------------------------------------------------
thread-unsafe 5.545M (± 7.9%) i/s - 27.565M