Quantcast
Channel: Performance Archives - Closer to Code
Browsing index pages (22 articles)
↧

Ruby and Rails Performance Roundup: The Backlog Edition

Yet again instead of tweets, a blog post. The backlog got out of hand - 40 of them this time. Usual caveat: every number below is whatever the author measured on their own machine with their own...

View Article


Small PRs, big speedups: The Ruby performance work you almost missed

Normally I just fire off a tweet when I spot a nice performance PR landing in Ruby. Lately I've been catching up on a backlog of Ruby performance work I'd bookmarked and never gotten around to - so...

View Article


Image may be NSFW.
Clik here to view.

One Thread to Poll Them All: How a Single Pipe Made WaterDrop 50% Faster

This is Part 2 of the "Karafka to Async Journey" series. Part 1 covered WaterDrop's integration with Ruby's async ecosystem and how fibers can yield during Kafka dispatches. This article covers another...

View Article

Ruby Floats: When 2.6x Faster Is Actually Slower (and Then Faster Again)

Update: This article originally concluded that Eisel-Lemire wasn't worth it for Ruby. I was wrong. After revisiting the problem, I found a way to make it work - and submitted a PR to Ruby. Read the...

View Article

Image may be NSFW.
Clik here to view.

WaterDrop Meets Ruby’s Async Ecosystem: Lightweight Concurrency Done Right

Ruby developers have faced an uncomfortable truth for years: when you need to talk to external systems like Kafka, you're going to block. Sure, you could reach for heavyweight solutions like...

View Article


Image may be NSFW.
Clik here to view.

Announcing Passive Queue: The Rails Background Job System That Transcends...

0ms processing time. Infinite scalability. 100% success rate. Zero failures. ← Give it a star if you enjoyed this zen approach! The Moment of Zen Clarity It was Day Two of RailsConf 2025 in sweltering...

View Article

Image may be NSFW.
Clik here to view.

Under the Hood: Enhancing Karafka’s CPU and Memory Efficiency

Introduction Now and then, I like to go on a performance improvement hunt because life isn't just about adding new features. Recently, I have been focusing on enhancing efficiency, particularly...

View Article

Image may be NSFW.
Clik here to view.

From Sleep to Speed: Making Rdkafka Sync Operations 16 Times Faster

As an open-source developer, I constantly seek performance gains in the code I maintain. Since I took over rdkafka from AppSignal in November 2023, I promised not only to maintain the gem but to...

View Article


Image may be NSFW.
Clik here to view.

The Art of Forking: Unlocking Scalability in Ruby

Introduction The journey towards efficient parallelization in library development has often been based on using threads. As Karafka celebrates its eighth anniversary, it's become clear that while...

View Article


Image may be NSFW.
Clik here to view.

Reduce your method calls by 99.9% by replacing Thread#pass with Queue#pop

When doing multi-threaded work in Ruby, there are a couple of ways to control the execution flow within a given thread. In this article, I will be looking at Thread#pass and Queue#pop and how...

View Article

Image may be NSFW.
Clik here to view.

The hidden cost of a Ruby threads leakage

Bug hunting Recently I’ve been working with one small application that would gradually become slower and slower. While there were many reasons for it to happen, I found one of them interesting. To...

View Article

Image may be NSFW.
Clik here to view.

The hidden cost of the Ruby 2.7 dot-colon method reference usage

Note: This case is valid also for the “old” #method method usage. The reason why I mention that in the “dot-colon” context, is the fact that due to the syntax sugar addition, this style of coding will...

View Article

Image may be NSFW.
Clik here to view.

Sidekiq Unique Jobs: don’t waste your time waiting – reschedule if busy

Half a year ago, I’ve made a post about Enforcing unique jobs in Karafka and Sidekiq for single resources. This approach is great, however, there’s a particular case in which Sidekiq Unique Jobs can...

View Article


Image may be NSFW.
Clik here to view.

Ruby: Stream processing of shell command results

There are various methods for calling shell commands in Ruby. Most of them either not wait at all for the results, or wait until the command execution is finished. In many cases it is ok, because...

View Article

Image may be NSFW.
Clik here to view.

Benchmarking Karafka – how does it handle multiple TCP connections

Recently I’ve released a Ruby Apache Kafka microframework, however I don’t expect anyone to use it without at least a bit information on what it can do. Here are some measurements that I took. How...

View Article


Image may be NSFW.
Clik here to view.

Empty? vs blank? vs any? – why you should not use any? to test if there’s...

I often work with junior programmers and somehow they tend to use syntax like this: return unless array_data.any? # or do something if array_data.any? And there’s almost nothing wrong with it, as long...

View Article

Image may be NSFW.
Clik here to view.

Ruby hash initializing – why do you think you have a hash, but you have an array

We all use hashes and it seems, that there’s nothing special about them. They are as dictionaries in Python, or any other similar structures available for multiple different languages. And that’s more...

View Article


Image may be NSFW.
Clik here to view.

Ruby global method cache invalidation impact on a single and multithreaded...

Most of the programmers treat threads (even green threads in MRI) as a separate space, that they can use to simultaneously run some pieces of code. They also tend to assume, that there’s no “indirect”...

View Article

Image may be NSFW.
Clik here to view.

Exceptions should not be expected – stop using them for control flow (or any...

If your exceptions aren’t exceptions but expectations, you’re doing it wrong. Here’s an example what programmers tend to do: def validate_status(user) case user.status when 'active' then return user...

View Article

Mongoid (MongoDB) has_many/belongs_to relation and wrong index being picked

Sometimes when you have a belongs_to relations, you may notice, that getting an owner object can be really slow. Even if you add index like this: class Activity include Mongoid::Document include...

View Article
Browsing index pages (22 articles)


Latest Images