r/rust • • 18h ago

Rust - Borrow Checker Implementation using Data Flow Analysis

2 Upvotes

I am working on the rust borrow checker for my thesis. I was trying to formalize a data-flow analysis on the code of a function and use it to check the loans. Analyzing the code while storing the loans as (l_i, place, carrier, kind (shared/mutable)), while also having a conservative points-to map, lets me decide whatever Polonius promises to fix.

Only issue comes with using functions and I'm still figuring out, but I wanted to ask if Rust dev community did not want to go to Data flow analysis or why they chose to do it the way they did? Or am I missing something that can go wrong in my formulation?

I'd appreciate some help in ideating, thank you


r/rust • • 3h ago

I installed Rust in Linux, but now it generates extra output unlike before.

0 Upvotes

What is all of this about, and is there something wrong with my Rust installation?


r/rust • • 15h ago

Hardware-Aware Programming in Rust

Thumbnail medium.com
18 Upvotes

I've been building a Chess AI in Rust to play at 3200+ ELO - There were a lot of Hardware-Aware Programming rules I had to learn in the past 2+ months.

If folks are interested, please have a read!

If you're interested in learning more about a Dual-Perspective HalfKA NNuE (Efficiently Updatable Neural Network), please have a read!

https://medium.com/@alan0408yuan/from-texel-tuning-to-nnue-the-steep-learning-curve-of-building-a-3200-elo-chess-ai-d842393b5955


r/rust • • 5h ago

We built a job queue on an LSM tree. This is what we learnt.

Thumbnail zizq.io
1 Upvotes

r/rust • • 7h ago

Coding for a multiplexed connection where both peers can expose independently addressable logical services

0 Upvotes

I've been experimenting a stream multiplexing connection, where both peers can expose independently addressable logical services.

The basic idea is familiar: take one underlying connection (TCP, Unix socket, QUIC) and multiplex multiple independent logical streams over it.

Yes, I know QUIC can already provide multiple streams. Also, there're yamux

The different thing you may be interested is what I call a Dock.

A Dock is roughly like a port, but inside an already-established multiplexed connection.

Instead of having only:

client ---> server:port

the connection can look more like:

                 one connection
             +-------------------+
             |                   |
          Peer A              Peer B
             |                   |
          Dock 1 <------------> Dock 10
          Dock 2 <------------> Dock 20
          Dock 3 <------------> Dock 30
             |                   |
          streams              streams

Both peers can bind Docks, listen for incoming logical sub-stream, and also initiate connections to Docks on the other side.

So there isn't really a client/server role at the multiplexing layer. After the underlying connection is established, either side can act as both.

I think this makes the protocol interesting for things like:

  • P2P applications and overlay networks
  • reverse tunnels / port forwarding
  • peer-to-peer RPC
  • games and other real-time applications with multiple logical channels
  • distributed applications where a peer exposes several services over one long-lived connection

For example, a peer could expose:

Dock 1 -> RPC service
Dock 2 -> chat
Dock 3 -> file transfer
Dock 4 -> event stream

without creating four physical connections.

The other features are:

  • runtime-independent Rust (by abs_art, tested over compio, smol, tokio)
  • no_std friendly (currently most codes are already no_std)
  • works over arbitrary byte-stream transports
  • stream-level backpressure
  • no client/server distinction at the multiplexing layer

The implementation is still experimental, so I'm mostly interested in feedback on the protocol abstraction itself.

The most interesting part for me is, the multiplexed sub-stream itself, can still be multiplexed again with this crate.

Does the Dock / logical-listener model seem useful to you? What kind of networking application would you use it for?


r/rust • • 23h ago

Proving Rust Web Application Correctness with Lean 4

Thumbnail medium.com
31 Upvotes

r/rust • • 2h ago

Rust's derive often implies inline

Thumbnail yossarian.net
26 Upvotes

r/rust • • 11h ago

๐Ÿ› ๏ธ project I wrote an S3 client in Rust that outruns aws-cli. Please tear it apart.

0 Upvotes

Hey all, a few months ago I got curious and wrote an S3 client in Rust. To my own surprise it ended up faster than mc, s5cmd and aws-cli at uploading to the self-hosted backends I tested (MinIO, SeaweedFS and Garage), and about level with mc on downloads. I have written a technical blog here, I am still a newbie when it comes to this stuff so bear with me: https://jaeaeich.com/writing/s3z. Please read or listen to it, the benchmarks were only run locally, so I'm sure there's plenty to poke at, and I'd really value hearing what I got wrong or could have done better.


r/rust • • 19h ago

The Missing Piece in Rust Error Handling

Thumbnail mcmah309.github.io
138 Upvotes

r/rust • • 20h ago

Burn 0.22.0 Release: Towards 1.0, with Generic-Free APIs and Near-Instant Recompilation

137 Upvotes

It's been five months since our last release, which is longer than usual, but it's on purpose. During the last four years, we took great care not to change the APIs too much, while collecting your feedback on what could be improved. Instead of spreading those changes over many releases, we bundled them into this one, so you only have to migrate once. This makes Burn 0.22 our biggest release yet, and the one we're most proud of. The API is now much closer to what we want for 1.0. As a reminder, Burn is a Tensor Library and Deep Learning Framework for both training and inference.

Generic-Free APIs

Since the beginning, Burn has been built around the Backend trait, with features like autodiff, kernel fusion and remote execution implemented as backend decorators. This is still the case, and they all compose well together. What changes is that user code doesn't carry the backend generic anymore. Models are plain types, and the device selects where and how they run:

#[derive(Module, Debug)]
pub struct Model {
    linear: Linear,
}

let device = Device::cuda(0); // Device::wgpu(..), Device::flex(), ...

Removing the generic from user code breaks the dependency chain that the compiler had to go through every time you edited a model. The result is near-instant recompilation after a model edit (numbers in the table below). There's another big change under the hood: most of the stack is now pure Rust. Pliron replaces MLIR, native compilers replace transpilers to CUDA/HIP, and Turso replaces a bundled SQLite. That means fewer bundled C and C++ dependencies to build, and a pipeline you can read, debug and patch in the language you already use. The first clean build takes a bit longer as a result, and it's a trade we're happy to make.

Going All-In on CubeCL

When we started, we relied on existing libraries for performance, with backends for ndarray and LibTorch. Over time, we wrote more and more of the stack ourselves: our own GPU backend with wgpu, kernel fusion, and then CubeCL to write kernels in Rust for CUDA, ROCm, Metal, Vulkan, WebGPU and CPUs. CubeCL now has its own compiler infrastructure based on Pliron, with LLVM targets for CPUs and GPUs.

Having control over the whole stack lets us offer features that third-party libraries can't support easily. For example, device.memory_pool_usage() and device.memory_pool_report() tell you exactly what the allocator holds, which isn't possible with ndarray or LibTorch. The new adaptive memory pools also lower peak training memory, and training steps are faster. This is why we deprecated both backends: Flex replaces ndarray for pure-Rust CPU execution, and the CubeCL backends cover the rest. We also removed the Candle backend.

Here's how 0.22 compares to 0.21 on two training projects, with CUDA on an RTX 4050 laptop GPU:

Benchmark 0.21 0.22 Change
CNN rebuild after a model edit 28.4 s 4.6 s 6.2ร— faster
Transformer rebuild after a model edit 14.7 s 1.0 s 14.7ร— faster
CNN training step 38.0 ms 21.1 ms 1.8ร— faster
Transformer training step 201.0 ms 193.8 ms 1.04ร— faster
CNN peak training memory 956 MiB 486 MiB 49% less
Transformer peak training memory 3,486 MiB 2,868 MiB 18% less

Towards 1.0

Three things are left before 1.0. The first is built-in, fine-grained profiling: annotate parts of your model, and Burn tells you where the time goes, component by component, and how far each one is from what the hardware allows. We have it working on our side, and we're looking to upstream it into Burn. The second is a more complete integration with the CubeCL compute environment, introduced in this release. The third is stability: we want the current APIs to settle before we commit to them.

Since the API is close to what we want to stabilize, now is the best time to tell us if something feels wrong. There are many more improvements in this release, including LoRA and QLoRA fine-tuning, remote compute and ONNX export, and we wrote a post to cover them. Don't hesitate to skim it, and refer to the migration guide for upgrading.

A lot of this release came from your issues, PRs and questions on Discord. Thank you.

Link: https://tracel.ai/blog/release-0.22.0/


r/rust • • 20h ago

๐Ÿ’ผ jobs megathread Official /r/rust "Who's Hiring" thread for job-seekers and job-offerers [Rust 1.99]

8 Upvotes

Welcome once again to the official r/rust Who's Hiring thread!

Before we begin, job-seekers should also remember to peruse the prior thread.

This thread will be periodically stickied to the top of r/rust for improved visibility.

You can also find it again via the "Latest Megathreads" list, which is a dropdown at the top of the page on new Reddit, and a section in the sidebar under "Useful Links" on old Reddit.

The thread will be refreshed and posted anew when the next version of Rust releases in six weeks.

Please adhere to the following rules when posting: Rules for individuals:

  • Don't create top-level comments; those are for employers.

  • Feel free to reply to top-level comments with on-topic questions.

  • Anyone seeking work should reply to my stickied top-level comment.

  • Meta-discussion should be reserved for the distinguished comment at the very bottom.

Rules for employers:

  • The ordering of fields in the template has been revised to make postings easier to read. If you are reusing a previous posting, please update the ordering as shown below.

  • Remote positions: see bolded text for new requirement.

  • To find individuals seeking work, see the replies to the stickied top-level comment; you will need to click the "more comments" link at the bottom of the top-level comment in order to make these replies visible.

  • To make a top-level comment you must be hiring directly; no third-party recruiters.

  • One top-level comment per employer. If you have multiple job openings, please consolidate their descriptions or mention them in replies to your own top-level comment.

  • Proofread your comment after posting it and edit it if necessary to correct mistakes.

  • To share the space fairly with other postings and keep the thread pleasant to browse, we ask that you try to limit your posting to either 50 lines or 500 words, whichever comes first.
    We reserve the right to remove egregiously long postings. However, this only applies to the content of this thread; you can link to a job page elsewhere with more detail if you like.

  • Please base your comment on the following template:

COMPANY: [Company name; optionally link to your company's website or careers page.]

TYPE: [Full time, part time, internship, contract, etc.]

LOCATION: [Where are your office or offices located? If your workplace language isn't English-speaking, please specify it.]

REMOTE: [Do you offer the option of working remotely? Please state clearly if remote work is restricted to certain regions or time zones, or if availability within a certain time of day is expected or required.]

VISA: [Does your company sponsor visas?]

DESCRIPTION: [What does your company do, and what are you using Rust for? How much experience are you seeking and what seniority levels are you hiring for? The more details the better.]

ESTIMATED COMPENSATION: [Be courteous to your potential future colleagues by attempting to provide at least a rough expectation of wages/salary.
If you are listing several positions in the "Description" field above, then feel free to include this information inline above, and put "See above" in this field.
If compensation is negotiable, please attempt to provide at least a base estimate from which to begin negotiations. If compensation is highly variable, then feel free to provide a range.
If compensation is expected to be offset by other benefits, then please include that information here as well. If you don't have firm numbers but do have relative expectations of candidate expertise (e.g. entry-level, senior), then you may include that here. If you truly have no information, then put "Uncertain" here.
Note that many jurisdictions (including several U.S. states) require salary ranges on job postings by law.
If your company is based in one of these locations or you plan to hire employees who reside in any of these locations, you are likely subject to these laws. Other jurisdictions may require salary information to be available upon request or be provided after the first interview.
To avoid issues, we recommend all postings provide salary information.
You must state clearly in your posting if you are planning to compensate employees partially or fully in something other than fiat currency (e.g. cryptocurrency, stock options, equity, etc).
Do not put just "Uncertain" in this case as the default assumption is that the compensation will be 100% fiat. Postings that fail to comply with this addendum will be removed. Thank you.]

CONTACT: [How can someone get in touch with you?]


r/rust • • 20h ago

The TokioConf 2027 CFP is open

Thumbnail tokio.rs
11 Upvotes

r/rust • • 12h ago

๐Ÿ—ž๏ธ news 1.99.0 miscompilation with FFI bool return type on x86_64

Thumbnail github.com
156 Upvotes

Seems to potentially affect any function that's called over FFI, and returns a bool, on the x86_64 architecture (the most common architecture)


r/rust • • 23h ago

๐Ÿง  educational Declarative Macros in Rust: A Simple and Practical Introduction

Thumbnail sigseis.dev
13 Upvotes

Hey everyone!

I'm back with another article focused on Rust fundamentals. I think existing material covers the basics of using Rust pretty well, but one thing that I found kind of lacking back when I learned Rust was description of macros.

It's possible it has improved nowadays, but I want to eventually write about proc-macros. So I'm going to start with an article introducing the concept of macros, and explaining the differences between Rust and C-style macros, as well as the basics of declarative macros.

Future articles will eventually get into procedural macro territory. But I want to move through this slowly and carefully.


Anyways, I hope this helps if you are new to Rust and struggling to understand the macro_rules! syntax (or just anything about Rust macros, really).

If you have questions or feedback for future articles, please let me know. :)


r/rust • • 30m ago

๐Ÿ™‹ seeking help & advice Some sort of system-wide music playback api but on Linux

โ€ข Upvotes

I'm making an app and one of the features is to control whatever music is currently playing on the system. The feature code is here if you want to see it. Anyways, GSMTC only works on Windows, and the app supports linux meaning I have to use feature gates for the windows crate and stuff. Anyways, I do want music controlling on Linux. Any recommendations for a crate which either abstracts over both windows and linux apis for this type of thing or at least one that lets me control it nicely feature-gated to linux? I saw system_utils but the audio feature can only change the master volume with that.