I am, of course, talking about std::future::Future . There are two ways of creating a Future in Rust, you can define some struct or enum , and then implement the Future trait on it or via Rust's async keyword. Any async block ( async { .. } ) or async function ( async fn foo() { .. } ) returns a future. If you want to learn more about how this works, have a look at my series of posts on how I…
I've been trying to get my head around the memory metrics reported by kubernetes and what the numbers mean. Especially since the gaps caused us problems a while back. (Thanks to Maksym and Chris for explaining!) My issue was that I hadn't entirely understood how page caches get represented in the cAdvisor metrics which you get from kubernetes. This is the best analysis I've found…
Usually, I like to write posts about things I understand. Even if this means that I have to go and understand something first. This post is going to be a bit different. Instead, we're going to follow along as I try to understand something. One of my favourite topics to write about is the tracing instrumentation in Tokio and how it can be used to better understand your asynchronous code.…
This is going to be a fairly in-depth post on understanding how we can follow task dependency edges using the tracing instrumentation available in the Tokio async runtime. Specifically related to determining which task (if any) woke some other task. It will cover some of the same ground as a post from last year tracing tokio tasks , but focus more on the waker events. If you haven't read that…
Not long ago, I came across a genuine case of code that needed optimising. I was really excited, as it's not every day that you can say this from the outset, and in this particular case, I was pretty sure that there was plenty of room for improvement, but I didn't know where. how did I know? One of our backend services was having trouble with the latency of the requests, up to such a…
The other day I was setting up release automation for a Rust project. Everything was going great and I'm happy with the release tooling I'm trying out. Then it got to creating the release PR. This looks great, it includes all the information about the release. The version that's being released, a changelog (which is customizable), as well as a link to the commits in the latest…
One of the things that is said about Rust is that it's the result of paying attention to the last 30 years of research into programming language design. This is probably being unfair to some other languages - even if only by omission. However, we can say that Rust has definitely made the right choices in some places where no widely successful programming language has done before. One of the…
I contribute to tokio-console . One of the things that I often find myself doing is matching what is shown in the console with the "raw" tracing output that comes from Tokio. However, this is pretty hard to read and doesn't actually contain all the information that I need. There are a couple of things that I'd like to have. Firstly (and most importantly), I need to see Tracing's…
This year I had the pleasure of speaking at RustLab . RustLab is a Rust conference in Florence, Italy. It is co-hosted with GoLab . (I imagine GoLab was a thing before RustLab) My talk was titled Observing Tokio . In it, I show-cased 3 tools which give insight into the Tokio async runtime. The metrics inside Tokio Tokio Console which uses the tracing instrumentation in Tokio The new task dumps…
Today we had the first Rust for Lunch meet-up. I was really happy with the result. As a bit of a post-mortem, I thought I'd write up the process. We'll start with the obvious question. Why create some new Rust meet-up? why a new meet-up? I like meet-ups. Or rather, I like the idea of meet-ups. Get together with a group of like-minded people. Hear interesting ideas on your common topic of…
Async programming can be tricky. Part of the reason for this is that your program is no longer linear. Things start. Then they pause. Something else runs. It pauses. The first thing starts again. The second thing runs. Then it finishes. Then the first thing pauses again. What a mess! It would be nice if we had a way to analyse what's going on. Even if it's after the fact. The good news…
You've reached the end of my series on understanding async/await in Rust. (the beginning of the end) Throughout the last posts we've asked a series of questions. The answers to those questions helped us understand how async/await works. We did this by looking at how to "manually" implement futures. (this is what the async / .await syntax hides from us) But that syntax is…
This is a series on how I understood async/await in Rust. This is part 3. Here's the full list: part 1: why doesn’t my task do anything if I don’t await it? part 2: how does a pending future get woken? part 3: why shouldn’t I hold a mutex guard across an await point? (this very post) part 4: why would I ever want to write a future manually? (available) Previously we looked at what…
This is the second part in a series on understanding async/await in Rust. Or rather, on how I understood async/await. As you're not me, this may or may not help you understand too. (but I hope it does) Here's the full list of posts in the series. part 1: why doesn’t my task do anything if I don’t await it? part 2: how does a pending future get woken? (this post right here) part…
Like an increasing number of Rustaceans, I came to Rust after async/await had been stabilised. (strictly speaking this isn't true, but close enough) I didn't understand what was happening behind those magic keywords. async .await This made it hard for me to grasp why I had to do things in a certain way. I wanted to share how I finally understood async Rust. We'll do this via a…
Update (2023-05-10): A new version of tokio-console is available including this change! Last week we merged a small set of cool changes in Tokio Console . They added support for tracking and displaying per task scheduled time. For the impatient amongst you, here's a screenshot. But what is a task's scheduled time? Actually, let's first make sure we're all on the same page.…
I'm back with more gotchas involving topology spread constraints . This post is effectively part 2 of something that was never intended to be a series. Part 1 explored topology spread constraints and blue/green deployments . To be really honest, both these posts should include an extra quantifiers: "in kubernetes on statefulsets with attached persistent volumes." But that makes the title…
This week I discovered a flaw in our topology spread constraints . It’s weird enough (or at least interesting enough) that I think it’s worth sharing. This is kubernetes by the way. And I'm talking about the topologySpreadConstraints field. (Did you know that k8s is just counting the 8 missing letters between the k and the s.) (I didn’t until I’d been using k8s in production for 2 years…
I've recently contributed a little bit to the Tokio project. The first issue I worked on was #4413 : polish: add #[track_caller] to functions that can panic . Now I'm going to tell you everything you didn't know that you didn't need to know about #[track_caller] . what Before Rust 1.42.0 errors messages from calling unwrap() weren't very useful. You would get something…
In 2020, COVID-19 hit Europe. But unless you're reading this in the far future, you already knew that. Like many companies with offices in Germany, mine put many of the staff on Kurzarbeit . Kurzarbeit means short work in German. A company reduces the working hours of some of its staff, in my case I went to 4 days a week. The salary is reduced proportionately, but the German government will…
The first post on hēg denu . Here's some code to look at. #!/usr/bin/perl chop ($ _ =<>);@ s = split / /; foreach $ m (@ s ){ if ($ m ==' * '){$ z = pop @ t ;$ x = pop @ t ;$ a = eval "$ x $ m $ z "; push @ t ,$ a ;} else { push @ t ,$ m ;}} print "$ a \n ";