Skip to content

Instantly share code, notes, and snippets.

@osyoyu
osyoyu / splitter.rb
Created July 24, 2025 10:16
splitter for ridgepole --export
c = File.read(ARGV[0])
f = nil
table_name = nil
c.each_line do |line|
if line =~ /^create_table/
# Table definition
table_name = line.match(/^create_table "([^"]+)",/)[1]
f = File.open(File.join(File.dirname(ARGV[0]), "schemata", "#{table_name}.schema.rb"), "w")
comment = line.match(/comment: "([^"]+?)", force/)
def proc2src(proc)
# Proc#source_location in Ruby 3.5+ returns a 5-tuple
path, start_line, start_col, end_line, end_col = proc.source_location
lines = File.open(path).each_line.drop(start_line - 1).take(end_line - start_line + 1)
lines[0] = lines[0][start_col..-1]
lines[-1] = lines[-1][0...end_col]
# remove { } / do-end
if lines[0] == '{'
lines[0] = lines[0][1..-1] # {
@osyoyu
osyoyu / bench.rb
Created October 12, 2024 05:46
Ruby の GVL をなくすと遅くなる
GC.disable
def sieve_of_eratosthenes(limit)
is_prime = Array.new(limit + 1, true)
is_prime[0] = is_prime[1] = false # 0 と 1 は素数ではない
(2..Math.sqrt(limit)).each do |i|
if is_prime[i]
(i * i..limit).step(i) do |j|
is_prime[j] = false
@osyoyu
osyoyu / _ruby-association-grant-2023-final-report.md
Last active March 20, 2024 08:56
Ruby のパフォーマンスプロファイリングの改善 (Ruby Association Grant 2023 最終報告)

Ruby のための新しいプロファイラ Pf2 の開発 (Ruby Association Grant 2023 最終報告)

Daisuke Aritomo (osyoyu)

新たな Ruby プロファイラ "Pf2" を開発し、Gem としてリリースした。既存のプロファイラにはない、以下のような機能を備えたプロファイラを目指し、現在も開発を継続している。

  • プロファイリングの対象とする Ruby Thread を制御できる
  • 実時刻 (wall time) ベースのプロファイルの場合、あるサンプル時刻において複数の Ruby Thread のサンプルを収集できる
    • 既存のプロファイラでは1つの Thread のみのサンプルを収集する
@osyoyu
osyoyu / a.rs
Last active December 10, 2023 15:53
associated function `new` is never used
// a/mymod.rs ではなく mymod.rs をむりやり使う
#[path="./mymod.rs"]
pub mod mymod;
@osyoyu
osyoyu / ruby-build-soleil-branch
Created November 12, 2023 07:57
ruby-build-soleil-branch
# Based on https://github.com/rbenv/ruby-build/blob/master/share/ruby-build/3.3.0-dev
install_package "openssl-3.1.4" "https://www.openssl.org/source/openssl-3.1.4.tar.gz#840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3" openssl --if needs_openssl_102_300
install_git "ruby-soleil" "https://github.com/soleil-rising/ruby.git" "soleil" autoconf standard_build standard_install_with_bundled_gems verify_openssl
@osyoyu
osyoyu / test
Created December 29, 2022 15:12
test
test
@osyoyu
osyoyu / bench.go
Created May 4, 2020 16:59
saikoh.tk benchmarker
package main
import (
"flag"
"log"
"net/url"
"sync"
"time"
"github.com/gorilla/websocket"
@osyoyu
osyoyu / 00_timeline.md
Created September 17, 2018 04:08 — forked from south37/00_timeline.md
ISUCON Cheat Sheet
@osyoyu
osyoyu / package.json
Created March 30, 2018 10:38
最近のpackage.json事情
{
"name": "foobar",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"dev-server": "webpack-dev-server",
"build": "NODE_ENV=production webpack"
},
"dependencies": {