r/rust•
Programmurr

Next-gen networking infrastructure with Rust and Tokio (Carl and Sean)

Posted Feb 21, 2021, 12:04 PM UTC

40316
VeganVagiVore•

They don't actually talk about anything AWS is doing.

Rough timeline:

  • 00:00 Backstory / Intro to Rust
  • 08:40 Carl is the guy who started Tokio? Dang
  • 10:55 "What makes Tokio and async Rust unique?"
  • 12:00 How async tasks are transformed into state machines by rustc
  • 13:50 How the Tokio runtime executes async tasks
  • 15:30 Thread safety
  • 18:05 Switches to Sean who talks about the 'mini-redis' example
  • 20:30 Explaining Arc
  • 22:00 Explaining Mutex
  • 25:50 Sean says mini-redis performs the same as Redis itself, with the default benchmark settings, for the subset they implemented. Even though it's just demo / example code.

This is probably good for beginners. I've been using Tokio (and Hyper) for a year and none of it was new to me.

It's amazing how fast Rust-the-ecosystem got this all figured out - When I started, I wasn't sure what the difference was between mio and tokio and hyper and rocket and actix.

Now I always reach for Hyper as my HTTP server lib, and always end up using Tokio as the async runtime. I don't know if Hyper is the fastest, but it does streaming bodies and it's easy to work with. I rarely have any situation like "Ugh Hyper is getting in my way!"

Every now and then, the GC needs to pause execution to collect garbage

I thought Java and Go (And C#) had concurrent GCs? The proponents are often saying that GC isn't that bad.

74
pjmlp•

I thought Java and Go (And C#) had concurrent GCs? The proponents are often saying that GC isn't that bad.

They do, including pauseless GCs in Java's case.

In what concerns C# (including other .NET languages) and Go, you can also do C++ style programming, but many keep to fail to learn how to do it.

https://devblogs.microsoft.com/aspnet/grpc-performance-improvements-in-net-5/

16
john01dav•

There's a program that I've been trying to write, and Java is the ideal language except for GC pause times (even 10ms is unacceptable if it happens more than once or so per minute). You mentioned that pauseless GCs exist, but when I tried to find more information I couldn't find anything actionable. All I found was Azul which looks like a proprietary solution that is only fit for if I'm the only person running my code (e.g. a website backend), but that isn't the case for me as I need to distribute to end users and I am looking for FOSS solutions (it's preferable to me to write it in Rust or C++ than to deal with a proprietary GC). Is Azul what you were referring to, or is there a pauseless GC that I'm unaware of?

2
nagatoism•

Try Java11 and ZGC. most time 1ms pause and free and java native.

5
matthieum•

I confirm, the switch from JVM 11 to JVM 13+ZGC has seen a dramatic reduction in GC pause times on our applications. There are still GC spikes (> 1 ms) but much more infrequent.

It's still not good enough for truly latency-sensitive work, but for only somewhat-latency-sensitive work it's not bad.

3
nagatoism•

Pauseless GC from Azul is called C4 and you need a license to have it.(expensive)

3
myrrlynbitvec•

as far as i know, they are both employed to focus on the Tokio project and associated work, and have little involvement in AWS internal or commercial work

12
oleid•

On the GC: it depends on what you need /expect. Those pauses are there and if you have lots of requests, some of these can take noticeable longer. This may or may not be an issue.

5
AstartesFartes•

I haven't tried hyper http server, but tide has proven very light and easy to work with for me.

1
akoncius•

nice! gave me another inspiration to learn rust :)

11
neofreeman•

That’s the thing I loved about Rust when I was working on https://github.com/maxpert/drep

I did evaluate solutions like C++, Go, Nim etc. Rust ended up being my favorite because I was just focused on the problem at hand and what I got was memory efficient and speedy program. Not even trying hard for speed and memory safety.

7