Polonius (next-gen borrow checker) nearing stabilization with promising performance already

672 points TomEntin 43 comments

As many of you probably know Polonius is the name of the next-gen borrow checker that allows more complex (but still valid) borrowing scenarios that the current borrow checker, NLL, rejects. NLL is "simpler" for the sake of performance, it rejects valid borrowing scenarios that are too complex since it is too simple to validate them.

An update was posted a week ago (linked) that claimed Polonius' performance is close to the current borrow checker:

On the 20000 most popular crates, the average is +1.4%. 75% of crates see a <2% regression, and 95% see a lower than 5% hit. The worst outliers see bigger times though of course, 36% at the 99.9 percentile of crates, and the worst we saw in these runs were huge functions that saw a 2.5x hit. These show good examples where we can find improvements, and we could still imagine running the more expensive analysis only if the cheaper NLLs find possible issues that would benefit from the precision. We'll also expand to more and more crates and see what lies there, though we expect more feedback to come from nightly users, when we turn polonius on there.

And about stabilization:

We believe the results so far wouldn't prevent enabling the polonius alpha by default on nightly, or even stabilize it as-is maybe. Stabilization is often the beginning of the performance work, as others join the improvement effort then.

Though Polonius isn't faster, it's still an improvement to the borrow checker, given it's pretty much the same speed already. I bet atleast half of the members here have had to alter their code in attempt to satisfy NLL.

Like what was said in the second quote block, once stabilized, it will become a priority to optimize it, and if it already performs as well whilst being in the alpha stage, who knows how fast it will be once matured.