Hacker News new | ask | show | jobs
by rafram 10 days ago
See uv - replacing pip with a rewrite in Rust was a good stunt, but the big performance gains came from eliminating dynamic features (uv doesn’t allow packages to execute code when installed) and I/O (better caching and parallelization).
3 comments

I think the biggest win of going from pip to uv is that breaking your python environment no longer breaks the tool to manage your python environment. Pip was always fragile in that you could carelessly use it to break a library it is depending on. (Yes, there are ways to avoid that - but they require not being careless.)
I once, on a fresh Ubuntu install, did "apt install python-pip3", and then "apt install python3.8" when I realized I actually needed Python 3.8. The pip3 complained that it was outdated and suggested a command to run to update it. Naturally, I ran it, and it completely broke apt, it couldn't even do "apt list" never mind intalling/removing packages, so I had to rollback the VM to fix this bullshit. Wonderful, 10/10 DevEx.
I'm not sure that's a compelling indictment of Python specifically, but you definitely make a good case for tools that are often needed as prerequisites for using other tools (package managers, decompressors, the basic drivers needed for HID, slow networking, VESA graphics, storage) being distributed in a self-contained way.

I'm not necessarily a "statically link all the things" zealot, but I think that pattern definitely has a place where problems like yours often occur.

Well, Ubuntu (and Debian) definitely have a fair share of blame for both weirdly insisting on packaging parts of Python standard library into separate apt packages, and also on setting the system-wide Python in such a way that packages from different Python versions will end up in the same site-packages/ directory, and also on making apt rely on system-wide Python which can be very easily broken by apt itself... tl;dr is that the only sane way to use Python on Ubuntu is to immediately get virtualenv (yes, it's too distributed separately from Python itself, you need to run "apt install python3-virtualenv" first) — and then never, ever touch system-wide Python or its packages with apt, upgrade the pip inside your venvs only.
Or install uv
Though to give credit where it's due, it's a lot easier to parallelize things well in rust than in python. The coarse-grained download parallelism is easy in both, of course (though with higher overhead in python), but the more fine-grained solver parallelism favors rust (or c/c++ but let's not do that).
Every cursed rust application I've been hired to fix has been diagnosed as spending 90%+ of its time pointlessly jumping tokio threads because someone thought that async means fast. I give these 10x throughput boosts by removing concurrency or, sometimes, just rewriting them in Go.
You're talking about concurrency and I'm talking about parallelism. :-)

Rust's async situation is still a pain in many ways.

But throwing Rayon at something often results in very reasonable parallel performance gains without cluttering things much. It usually won't get you to an optimal solution, but it's good for 80% with 10% of the pain.

I interpreted GP as talking about maintaining Rust code that was written with performance in mind by people who were not familiar with the difference, and who shot themselves in the foot as a result.
It depends on what you are going for: service latency, or throughput. Rayon's work stealing is inappropriate for any throughput oriented work and questionable for the majority of latency sensitive services. It does have a niche but it's not the first thing I would reach for. Unfortunately it IS the first thing Claude reaches for.
That's why the rust server I work on is an unholy mix of threads and tokio...

The performance oriented (data plane) work happens on dedicated, cpu-pinned threads and sockets outside the tokio runtime. The control plane work happens in tokio async. Interaction between the two is tricky. But decreased latency and increased throughput is valuable. And it's a complex server, so we can't really try too many approaches.

It certainly doesn't help that the data structures are, by necessity, a cephalopod that have to be used across threads.

Rust makes it pretty hard to do fast async, IMO.

Everything wants to push you down the path of using `ARC<Thing>` even when `Thing` is immutable or the lifetime can be mostly guaranteed.

Here's an example of that problem. Let's say I want to do 2 things concurrently against the same data set. I might want to write code that looks like this:

    let v = vec![1, 2, 3];
    let taskA = tokio::spawn(async {
        println!("Here's a vec: {:?}", v);
    });
    let taskB = tokio::spawn(async {
        println!("Here's a vec: {:?}", v);
    });
    tokio::join!(taskA, taskB);
But that immediately gets you in hot water because "async block may outlive the current function, but it borrows `v`, which is owned by the current function"

Now, you and I can clearly see that the async block does not, in fact, outlive the current function. However, AFAIK, there's no real way to convince rust that that is the case.

So now even though `v` is immutable, making this a thread safe operation, we need to introduce unnecessary concurrency constructs or break out unsafe in order to force the language to recognize that "Yes, you can trust me".

For rust to actually be fast with concurrent operations, it needs to be smarter about lifetimes in terms of async.

You don't need to spawn tasks for concurrency.

https://docs.rs/tokio/latest/tokio/macro.join.html

Yeah, and the amount of work that rustc has to do contemplating the safety of these async bodies, their witnesses, etc, especially if the signature is generic, explains most of the reason why rust builds are so long.
Absolutely. I have the exact same problem dealing with Python people who have done the same thing. "This is all modern, async python and therefore can scale. What do you mean our event loops are routinely blocked?!"

I thought we as an industry had hopefully moved past "async == magic code-go-fast sauce", but apparently we have not.

As much as Go annoys me, you're right there as well. I have to admit that Go did "solve" the make-concurrency-and-parallelism-accessible (and relatively safe) space in a way that very, very few other programming languages did (and none that people widely use).

> and none that people widely use

Java already did, especially now with virtual threads. Now other JVM languages can also get this benefit.

Java solved half of it: the risk of race conditions creating data corruption. But it didn't solve efficient threading or IO multiplexing (at least until virtual threads arrived recently), which put a damper on the ability of folks to use the language's concurrency primitives to model units of business logic; that'd just create too many threads even on a modern system. Goroutines have no such issue.

Erlang, as the adjacent comment points, out, did solve that! But at such a significant runtime (performance/memory) and syntactic cost that it's very rarely used, even nowadays after the Elixir renaissance.

Erlang BEAM VM
What absolutely kills me is people who go the other way, hard-line refusal to ever block an executor, then a few days into it they decide they need "backpressure" which they would have got FOR FREE if they had just stayed on the main event loop.
Eeeeh...backpressure via loop blocking only kinda-sorta works, with some nasty externalities. If you're doing heterogenous work (e.g. serving lots of different web routes on one server and only want to backpressure some) loop-blocking can have an unwelcome blast radius, plenty of telemetry/sidecar-ish systems will either bug out or alarm if the loop's blocked, and some event-loop-based systems will start to struggle processing signals/shutting down the runtime while the loop's blocked as well.

Loop-blocking-as-backpressure is sometimes the right move, but only rarely. If you can isolate event loops for specific workloads (e.g. some shameless self promotion, releasing in PyPi this week: https://github.com/zbentley/async-anywhere/blob/main/src/asy...) that becomes a more tractable approach.

There are multiple ways to do it, sure. But I really hate hydraulic analogies and what people want from "backpressure" is what you get from simply not accepting and reading sockets quite as eagerly. You can always read a socket later. That's how TCP works.
Yes exactly, I think this article explains it well :- https://nesbitt.io/2025/12/26/how-uv-got-so-fast.html