Skip to content

Instantly share code, notes, and snippets.

@paddor
paddor / 1brc_ractors.rb
Last active January 15, 2024 19:11 — forked from codekitchen/1brc_ractors.rb
Exploring the 1BRC in Ruby with Ractors
#!/usr/bin/env ruby --yjit
WORKER_THREADS = 4
CHUNK_SIZE = 2**16
# BUG: my city struct is being corrupted when moving from the worker to the main ractor.
# `#<struct City min=-11.3, tot=24088.30000000004, max=64.6, n=1164>` becomes
# `#<struct City min=-11.3, tot=24088.30000000004, max=64.6, n=nil>`, note that each `n` attribute becomes `nil`.
# https://bugs.ruby-lang.org/issues/20165
# I tried changing the Struct to a simple array and still using `move: true`,