Samuel Williams Tuesday, 31 December 2019

This month has been productive. I have been recovering from 6 weeks of travelling in Japan, and I've had to focus more on commercial work, however I was still able to continue development on my open source projects.

Ruby 2.7

The release of Ruby 2.7 included performance improvements to thread allocation, reduced memory usage for threads and fibers, and significantly reduced overhead for fiber reuse. I am now implementing improvements to the underlying I/O subsystem, including hooks for concurrency which can be easily implemented across all major implementations of Ruby.

Falcon

While I haven't had as much time to dedicate to falcon as I wanted, I have been receiving a lot of feedback which has helped me shape the design of the server. Within the next month, I hope to release falcon host which will be the first official mechanism for production deployment. This will hopefully include support for application preloading and I'm also considering options for an internal watchdog task to better manage server reliability and latency.

If you are a company and you are interested in trying falcon, please feel free to get in touch if you want to work together on a project.

Process Metrics

We recently migrated RubyAPI.org to use Falcon. It runs inside Heroku and initially we had some memory usage issues, because Falcon would fork one process per CPU core, which would quickly exceed the Heroku memory limit. As a consequence, I started experimenting with a code preloading within Falcon and looking at how it affected memory usage.

Traditional reporting of memory usage does not accurately capture real memory usage when considering multiple processes which have shared memory regions. Proportional set size (PSS) is a measurement of shared pages, divided by the number of processes sharing those pages, so more accurately represents actual memory usage, especially when summing the memory usage of multiple processes. Understanding both PSS, and unique set size (USS) is critical to understanding how falcon is using memory and whether preload is reducing memory bloat.

Linux provides /proc/<pid>/smaps which includes all the metrics required to compute the PSS and USS for a given set of processes, but it is non-trivial. In addition, I wanted to try and capture similar statistics from Darwin. So, I have been building the process-metrics gem, which provides all this information. The interface is still very immature and will likely change, but I've already integrated it into the falcon supervisor so you can pull this data from a running host.

Hopefully we can build this into a more elaborate report within Falcon in the future, and use it to drive the development of code preloading mechanisms which reduce the cost of production deployments.

Faraday

I recently added support for persistent connections to Faraday, which when backed by async-http-faraday, provides persistent HTTP/1.1 and HTTP/2.0 connections. This allows existing code built on top of Faraday to scale better when used with async.

Async::Pool

I recently released async-pool, a gem which extracts the pool implementations from async-redis and async-http. It provides support for multiplexed client resources (or singleplex if you set concurrency to 1), and will serve as a useful foundation for other client implementations, including several new async-safe database adapters which are in the works.

Programming Language Posters

A fruitful collaboration between Canterbury University, Dr. Tim Bell, Jack Morgan and myself, we recently released updated programming language posters. This free set of posters implemens the Fizz Buzz game in 13 different languages, and was designed for use in schools and universities to bring awareness to different progrmaming languages and help people overcome internal biases towards specific languages.

Sponsorship

This work is supported by my GitHub sponsors. If you are a company and you depend on Ruby, I invite you to support my work. I also provide commercial support agreements and contracting for businesses that want to improve their infrastructure using Falcon and Async.

Comments

Leave a comment

Please note, comments must be formatted using Markdown. Links can be enclosed in angle brackets, e.g. <www.codeotaku.com>.