hauleth

hauleth

Scotty, I need warp speed in three minutes - my journey in optimising Elixir codebase

I have recently spent some time optimising the hell out of my fork of Supabase’s Supavisor. I wanted to make it as fast as possible to compare it against “state of the art” and “native” solutions like PgBouncer and PgDog.

I haven’t achieved comparable performance, but I think that the read may be interesting to some people out there.

Most Liked

rkallos

rkallos

Nice post! And thank you for the shout-out, and your many contributions to Peep :slight_smile:

I think your post is currently missing the links to Ultravisor and Speedoscope.

This project now lives as [Ultravisor][]
[…]
That has disadvantages, but at least it was workable within [Speedoscope][]

Aside: Did you happen to explore using Linux’s perf(1) for less-obtrusive tracing? It’s a bit clunky to use (or maybe I haven’t found a better way of wielding it), but I find it super helpful, especially since the BEAM emits perf maps for jitted functions. When I was spending a lot of time trying to optimize stuff, which runs in a Docker container in prod, I repeatedly ran perf(1), and generated flame graphs (using GitHub - brendangregg/FlameGraph: Stack trace visualizer · GitHub ) like so:

# copy perf map out of Docker container, making it visible to perf running on the host.
sudo docker cp container:/tmp/perf-6.map /tmp/perf-2969015.map
sudo perf record --call-graph=fp --pid 2969015 -- sleep 10
sudo perf script > out.perf
sudo chown richard:richard out.perf
./FlameGraph/stackcollapse-perf.pl out.perf > out.folded
# strip [0-9]+_ and/or _[0-9]+ from all scheduler names
sed -e 's/^[0-9]\+_//' -e 's/^erts_\([^_]\+\)_[0-9]\+/erts_\1/' out.folded > out.folded_sched
./FlameGraph/flamegraph.pl out.folded_sched > out_sched.svg

These flame graphs weren’t totally complete (i.e. they missed stuff from NIFs compiled in the container without debug symbols), but it was nice to get a mix of BEAM and native code in a single flame graph.

dimitarvp

dimitarvp

This was an enjoyable read, thank you. I’ll try using Peep soon as a result.

Where Next?

Popular in Blog Posts Top

jordiee
https://medium.com/@jpiepkow/team-based-login-with-accesspass-be236d4bd7dd
New
brainlid
Elixir has a built-in Zip library that comes with OTP. This post explores how to use the zip module and asks the important question: “Is ...
New
lawik
We all have varying degrees of exposure to Big Tech. Some of it seems fine, stable and can be relied on. Some of it feels like shifting s...
New
ConnorRigby
Just finished a post for Embedded Elixir and I thought it should be cross-posted here: https://embedded-elixir.com/post/2018-09-25-mocks...
New
axelson
I describe how we use Hot Reloading with Webpack to develop faster and show how to integrate Webpack 5, webpack-dev-server, and Phoenix f...
New
marcin
Hi! :waving_hand: I wanted to refresh my knowledge on how to mix phx.gen.auth with local password users db, as well as OAuth providers s...
New
rlopzc
Use the new log handlers to plug Slack or any other provider into your logging system. https://rlopzc.com/posts/integrate-slack-into-the...
New
brainlid
Phoenix 1.7.0 brings a lot of new things when we run mix phx.gen my_app. These new and cool ways of doing things aren’t automatically bro...
New
AstonJ
Just finished doing a clean install of macOS (which I highly recommend btw!) and have updated my macOS Ruby & Elixir/Erlang dev env s...
New
davydog187
Hello all! I wrote a blog post called Elixir Observability: OpenTelemetry, Lightstep, Honeycomb. The post post covers how to integrate ...
New

Other popular topics Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement