r/ruby • • Jan 06 '26

Question Any way to reduce object allocation for protobuf in ruby

2 Upvotes

I’m working on a low-latency, read-heavy system in Ruby (2.7.6 — upgrade in progress) and using LMDB as an in-memory cache.

Current setup: • Puma in multi-process mode, each process with 8 threads • LMDB used as a shared, read-optimized cache • Cache values stored as Protobuf • I initially used a custom binary struct format, but dropped it due to schema evolution concerns

Problem / concern: When reading from LMDB, the Protobuf value needs to be parsed into Ruby objects. I want to minimize memory allocations during deserialization so that: • GC pressure stays low • Peak latency doesn’t spike under load

The system is currently read-heavy, and avoiding excessive object creation on the hot path is a key goal.

I’m considering different approaches (FFI, C extensions, zero-copy reads, etc.), but before going deeper I wanted to sanity-check the design.

Questions: • Am I missing any obvious pitfalls with this approach? • Are there known techniques to reduce allocations when deserializing Protobuf in Ruby? • Would a C extension / FFI reader realistically help here, or does the Ruby object model negate most of the gains?

Would appreciate any insights from folks who’ve built low-latency systems in Ruby or used LMDB/Protobuf in similar setups.


r/ruby • • Jan 05 '26

Portable mruby binaries with Cosmopolitan

Thumbnail katafrakt.me
27 Upvotes

A new nice addition to mruby which I discovered few days ago.


r/ruby • • Jan 05 '26

Screencast Self Hosted App

Thumbnail
driftingruby.com
16 Upvotes

In this episode, we'll go from a fresh Rails 8 application and a newly provisioned Raspberry Pi to deploying the application on the PI. We'll also set up a domain to point to this application and put in place geo restrictions to help prevent unwanted access.


r/ruby • • Jan 05 '26

Transition to Ruby / On Rails

Thumbnail reddit.com
5 Upvotes

r/ruby • • Jan 04 '26

Show /r/ruby Stimulux: Stimulus js without brain gymnastics with helpers for 'data-' atributes generation in Phlex and HtmlSlice

19 Upvotes

Hello, I made this gem inspired by Symfony StimulusBundle, but for Phlex and HtmlSlice. What are your thoughts about it?

https://github.com/henrique-ft/stimulux

The goal is to improve productivity and legibility while working with Stimulus inside Ruby html generation gems.


r/ruby • • Jan 03 '26

Why is my regex returning true when it's not an exact match?

4 Upvotes

I can't ask this in s/o because the wording is so common and it's flagging it as a dupe, not sure how else to rephrase.

According to regexr.com, abcd is not a match for my regex \bd*\b. But in my console, I get this:

[18] pry(main)> "abcd".match?(/\bd*\b/)
=> true

I am expecting false because the only thing that should match is a single d or d repeating. Here is exactly what I tested: https://regexr.com/8j4rp


r/ruby • • Jan 03 '26

Grepfruit v3.2: Programmatic API for Text Search

17 Upvotes

Grepfruit, a ractor-powered text search gem, adds a programmatic API in v3.2, a count-only mode, and Ruby 4 support.

What's new?

Programmatic API

The gem can now be used programmatically directly in Ruby applications:

Grepfruit.search(
  regex: /TODO/, 
  path: "spec/test_dataset", 
  exclude: ["foo.md", "baz.py"]
)

# returns =>

{
  search: {
    pattern: /TODO/,
    directory: "/Users/username/Development/grepfruit/spec/test_dataset",
    exclusions: ["foo.md", "baz.py"],
    inclusions: []
  },
  summary: {
    files_checked: 2,
    files_with_matches: 2,
    total_matches: 4
  },
  matches: [
    {file: "bar.txt", line: 3, content: "TODO: Fix the alignment issue in the header."},
    {file: "bar.txt", line: 7, content: "TODO: Update the user permissions module."},
    {file: "bar.txt", line: 14, content: "TODO: Review the new design specifications."},
    {file: "folder/bad.yml", line: 21, content: "# TODO: Add configuration for cache settings"}
  ]
}

All CLI options are available as keyword arguments, and the API returns structured data that should be easy to work with in Ruby scripts.

Count-only mode

Use the --count flag (or count: true in the API) to show only match statistics without displaying the actual matches.

Ruby 4 support

Grepfruit now supports Ruby 4 and its updated ractor implementation.

Check out the gem here.

Happy coding!


r/ruby • • Jan 03 '26

🚀 Added Editor Theme Support to PicoRuby Calculator!(M5 Cardputer)

Thumbnail
gallery
62 Upvotes

Happy New Year! 🎍☀

I’m Hamachan, a Rubyist from Japan ✌

I’ve just added a new “Editor Theme” feature to my PicoRuby Calculator! You can now type PicoRuby code in an editor-like environment on the M5 Cardputer and execute it directly ⚡️

It makes the calculator feel much more like a tiny handheld Ruby editor.

Put Ruby in your pocket and take it out into the city ☕🚶‍♂️ → https://github.com/engneer-hamachan/picoruby-calculator

And if you like it, I’d really appreciate a star! ⭐️


r/ruby • • Jan 02 '26

Show /r/ruby Exploring Ruby’s potential outside of Rails — an early-stage Ruby TUI experiment

67 Upvotes

I started building a Ruby TUI file manager because I wanted to explore Ruby’s potential

outside of Rails.

rufio is an ongoing experiment in building interactive terminal software with Ruby.

It’s still early and imperfect, but I’m iterating on it steadily and learning along the way.

The current focus is on:

• Vim-like, keyboard-driven navigation

• fast filtering and search

• a plugin system extensible in Ruby

• optional native (Rust / Go) components for performance-critical parts

This project isn’t about competing with Rust tools.

It’s more about understanding where Ruby works well beyond web frameworks,

especially for TUI-style software.

Feedback or thoughts from people using Ruby outside of Rails would be very welcome.

GitHub: https://github.com/masisz/rufio


r/ruby • • Jan 02 '26

executorch-ruby: Run PyTorch models in Ruby

Thumbnail
github.com
26 Upvotes

I built Ruby bindings for Meta's ExecuTorch runtime. You can now run exported PyTorch models (.pte files) directly in Ruby apps.

GitHub: https://github.com/benngarcia/executorch-ruby

Feedback welcome! This library will likely be a critical part of my companies workflows, and I have my own list of priorities for continued development, but hoping to hear more from other users.


r/ruby • • Jan 02 '26

I updated my Rails Tabler starter to Rails 8.x and Tabler 1.x

8 Upvotes