RSSAmplifier

Blog

Peter Zhu

Peter's personal blog mostly about programming and sometimes other stuff.

blog.peterzhu.caRSS feed ↗29 posts

Latest posts

Open Source is the Most Fragile and Most Resilient Ecosystem

Some of my thoughts on the lessons we can learn from the RubyGems situation and how we can move forward.

Reworking Memory Management in CRuby

Shopify sponsors and collaborates with academia to take Ruby to new heights. In this post, we give an overview of what we've built in collaboration with the Australian National University.

Implementing Embedded TypedData Objects

We implemented a new feature to TypedData objects in Ruby, called embedded TypedData objects. TypedData objects are used across a wide variety of Ruby types, such as Time, Enumerator, and Method. This feature improves allocation speed and runtime performance, while decreasing memory usage. In this blog post, we'll look at what TypedData objects are under the hood, how embedded TypedData objects…

Finding Memory Leaks in the Ruby Ecosystem

Until recently, Ruby lacked a mechanism for detecting native-level memory leaks from within Ruby and native gems. This meant that it was hard to analyze Ruby applications that suffered from memory leaks, causing them to consume increasing amounts of memory until the system runs out and terminates the application. In this blog post, we'll be looking at the RUBY_FREE_AT_EXIT feature, which allows…

Autotuner: How to Speed Up Your Rails App

Ruby's garbage collector is designed to be adaptable, scaling from short Ruby scripts to running apps that serve millions of requests per second. While it's designed to be adaptable, it may not work optimally for every use case. For this reason, Ruby's garbage collector supports many parameters that can be used to tune it. However, the use of these parameters requires knowledge into how the…

A Rubyist’s Walk Along the C-side (Part 11): Debugging

Tips and tricks for the inevitable day: when the C extension crashes.

Two Garbage Collection Improvements Made Our Storefronts 8% Faster

At Shopify, we are constantly improving the performance of Ruby for everyone. Based on analysis of and experiments on one of our largest and highest traffic apps, we found two improvements in Ruby's garbage collector that significantly improved our garbage collector performance, which in turn reduced our response times by 8%.

Garbage Collection in Ruby

Overview of how Ruby's garbage collector works.

Open Sourcing Shopify’s Ruby Builds

We've open sourced the definitions to build the Ruby we use at Shopify in development, testing, and production.

A Rubyist’s Walk Along the C-side (Part 10): Benchmarking

Tools and methodologies to benchmark Ruby code.

Optimizing Ruby’s Memory Layout: Variable Width Allocation

Learn more about Variable Width Allocation, a new feature in Ruby 3.2 that improves performance by optimizing Ruby's memory layout.

A Rubyist’s Walk Along the C-side (Part 9): Circular Buffer Project

Practice your C extensions skills with a small project.

A Rubyist’s Walk Along the C-side (Part 8): Exceptions & Error Handling

Sometimes things don't go as expected and need to raise or rescue from errors.

rb_gc_force_recycle is Deprecated in Ruby 3.1

Are you a maintainer of a Ruby native extension gem? rb_gc_force_recycle will be deprecated in Ruby 3.1. Read to find how it affects you.

A Rubyist’s Walk Along the C-side (Part 7): TypedData Objects

Let's look at this special type of object that only exists in C extensions called TypedData objects.

How ruby_memcheck Finds Memory Leaks in Native Gems

Let's look at the internals of ruby_memcheck, a tool to find memory leaks in native gems.

To Free or Not to Free: A Story About a Memory Leak in Strings

Finding and fixing a memory leak in Ruby strings.

A Rubyist’s Walk Along the C-side (Part 6): Classes & Object Oriented Programming

Defining classes and modules and creating instances of classes.

A Rubyist’s Walk Along the C-side (Part 5): Variables

Reading and writing instance variables, class variables, global variables, and constants through the Ruby C API.

A Rubyist’s Walk Along the C-side (Part 4): Primitive Data Types

The primitive data types in the Ruby C API and how to use them.

A Rubyist’s Walk Along the C-side (Part 3): Calling Methods

Calling Ruby methods in C extensions.

A Rubyist’s Walk Along the C-side (Part 2): Defining Methods

Defining Ruby methods in C extensions.

A Rubyist’s Walk Along the C-side (Part 1): Hello World!

Let's look at how to set up and build your first Ruby C extension!

A Rubyist’s Walk Along the C-side

A series on writing your very first Ruby C extension, from scratch!

1.5 is the Midpoint Between 0 and Infinity in Ruby

What's the midpoint between 0 and infinity in Ruby? It's 1.5 for some reason. What's the reason you might ask? Read on to find out.

The Ruby Inplace Bug

A story about memory corruption inside Ruby when you create strings the wrong way.

Creating Ruby Strings in C

There are many different ways to create Ruby strings in C, and choosing the wrong one can have catastrophic effects. So which one do you choose?

Garbage Collection in Ruby 3.0

Overview of how Ruby's garbage collector works in Ruby 3.0.

Tips and tricks in MRI Ruby development

Tips on development, tools, and debugging in MRI Ruby.