🙋 questions megathread Hey Rustaceans! Got a question? Ask here (49/2026)!
Mystified about strings? Borrow checker has you in a headlock? Seek help here! There are no stupid questions, only docs that haven't been written yet. Please note that if you include code examples to e.g. show a compiler error or surprising result, linking a playground with the code will improve your chances of getting help quickly.
If you have a StackOverflow account, consider asking it there instead! StackOverflow shows up much higher in search results, so ahaving your question there also helps future Rust users (be sure to give it the "Rust" tag for maximum visibility). Note that this site is very interested in question quality. I've been asked to read a RFC I authored once. If you want your code reviewed or review other's code, there's a codereview stackexchange, too. If you need to test your code, maybe the Rust playground is for you.
Here are some other venues where help may be found:
/r/learnrust is a subreddit to share your questions and epiphanies learning Rust programming.
The official Rust user forums: https://users.rust-lang.org/.
The unofficial Rust community Discord: https://bit.ly/rust-community
Also check out last week's thread with many good questions and answers. And if you believe your question to be either very complex or worthy of larger dissemination, feel free to create a text post.
Also if you want to be mentored by experienced Rustaceans, tell us the area of expertise that you seek. Finally, if you are looking for Rust jobs, the most recent thread is here.
🐝 activity megathread What's everyone working on this week (49/2026)?
New week, new Rust! What are you folks up to? Answer here or over at rust-users! And for your project showcases, there's also /r/madeinrust – pay them a visit, too!
r/rust • u/fschutt_ • 10h ago
The Laravel You Know, Written in Rust (by Laravel team)
youtube.comr/rust • u/Old_Tax4792 • 21h ago
Vibe-coding Rust slop at work is killing my motivation
My team started writing internal tooling in Rust purely because it’s trendy....even though our actual product is in a completely different language.
the worst part is that nobody knows rust... Not the syntax, not Cargo, not the borrow checker. They’re just using LLMs to generate mountains of unreadable code, which it just works fine for that complexity of the tooling.
I started learning rust pre-AI and built a few cli tools with it on my own time.
Now I actively avoid touching it because of this AI slopfest...
Is it only me?
r/rust • u/Decahedronn • 7h ago
🛠️ project Speeding up voice activity detection by... just doing less work
4 months ago, I released version 1.2 of Earshot, a ridiculously fast, accurate, #![no_std] voice activity detection crate.
In my announcement post for 1.2, I said this:
[Earshot 1.0] runs at a little over 10μs per 16ms frame. I'm confident that could be sub-7μs with a bit more effort.
Well, how does 4.4μs (3,600x faster than real time) sound? How about a smaller binary, too? And even better accuracy?
Well, how does 840ns (~20,000x faster than real time) sound? How about even better accuracy? And a larger binary? Wait, no, scratch that last one...
Earshot 2.0 is the fastest VAD, faster than even the infamous WebRTC VAD. Unlike WebRTC, its accuracy is strong, with AUROC sitting between Silero VAD v6 and TEN VAD, two of the most widely used VAD models. Earshot 2.0 is 100x faster than either of them.
In hindsight, it was a bit silly to call Earshot 1.0 "ridiculously fast" at only 1,600x real time, 'cause what do I even call 20,000x? Insanely fast? Ludicrously fast? Preposterously fast?!
Precisions, precisions
Earshot 1.2's speedup over 1.0 came primarily from using fixed-point arithmetic instead of floating-point in some places. I think my original announcement post provided a decent explanation, but to summarize: floats are slow because the point, well, floats; instead, just use integers and pretend the decimal point stays at digit X, like counting cents instead of dollars.
You do lose some precision that way: 0.3 is (near-)perfectly representable in f32, but in the fixed-point "Q7" format, you only get 7 bits to represent the decimal, so the closest you can get is 0.296. Earshot uses a neural network; neural networks are trained using floating-point arithmetic, and they don't like running with different precision characteristics than what they were trained with. Earshot 1.2 used quantization-aware training (QAT) to train the model to expect the precision loss that comes from fixed-point, but my implementation of QAT kind of sucked! I won't get into details, since this is r/rust, not r/machinelearning. But the consequence was that I could only convert some of Earshot's neural network (specifically the recurrent & output layers) to fixed-point; the earlier layers had to remain floating-point to avoid total accuracy collapse.
With 2.0's new QAT implementation, I was finally able to convert the whole neural network to fixed-point! And that netted a performance improvement of... well, not much: a few hundred nanoseconds. Crap, no free lunch this time. What became fixed-point was the neural network's frontend: three 2D convolution layers that identify the most notable patterns over the past ~60ms of audio features. The bottleneck there wasn't from floating-point so much as the terrible way I implemented Conv2D. I replaced branching padding checks with pre-padding, making the loops easier to auto-vectorize. The first convolution layer included a max pool after a pointwise convolution expanded each feature from 1 channel to 16. I naively did the max pool over the 16-channel output, but since each output channel is just 1 multiply on the single input channel, I could do the pooling work before the pointwise conv when there's still only 1 channel instead of 16. Both of those changes saved another 100ns.
Twiddledum
If I wanted to improve things further, I was gonna have to look at the formidable beast the frontend gets its audio features from: the preprocessor. The preprocessor's first step is to perform a short-time Fourier transform over the last 3 frames of audio: 768 samples in total, since each frame is 256 samples. I initially nabbed the fantastic microfft crate to perform the FFT, since its embedded-first design suited my goal well. Back then, that goal was simplicity, but now, it's speed baby, and microfft unfortunately isn't gonna cut it. The first problem: it implements radix-2, which requires the FFT window to be a power of 2. 768 is not, so I was padding it with zeros to 1024. How wasteful! Radix-2 also meant that it did 9 butterfly passes over the data, on top of 2 additional passes for reordering & recombining - all that means more memory traffic & less speeeeeeed!1!
After taking an embarrassing length of time to only kinda-half-sorta understand FFT, I wrote my own preprocessor that does as few passes as possible over the unpadded 768-sample window. The new preprocessor only does 4 passes: radix-8 + Hann window → radix-4 → radix-4 → radix-3 + power spectrum. Got all that? Me neither. But it cut the FFT's processing time by almost half! The next step was obvious: let's convert it to fixed-point, too! After spending another few days to do that (I'm more persistent than I am bright), I managed to cut the FFT step down by another 2x. Did I say cut? Sorry, I meant slowed. The floating-point FFT was faster than the fixed-point one because the fixed-point implementation uses a lot of 64-bit multiplies, for which there aren't SIMD instructions (at least in AVX2). It also does a multiply + rounding add + shift for operations that the float preprocessor would do with a single multiply. I switched back to the floating-point preprocessor, keeping the fixed-point preprocessor tucked away for microcontrollers that don't have FPUs.
I finished with some other boring minor wins for the last part of the preprocessor (the log-mel filterbank + normalization), including:
- Switching base-e log for a cheap base-2 log approximation
- Using cheaper non-overlapping auto-vectorizable mel filters
- Ditching RMS normalization for simple linear operations
These changes netted another ~90ns improvement and conveniently dropped the libm dependency as well.
Ohh, I 'member!
Recall that the frontend can only see the last ~60ms of audio. That's not really enough to definitively tell if something is noise or speech; even if it were, speech includes a lot of pauses longer than 60ms (think especially of plosive sounds like p/b). If you want a useful VAD model, it's gonna need a longer-term memory than just 60ms. Expanding the window seen by the frontend would be wasteful, though: we'd be redoing a lot of math over the same data on each frame. A better solution would be to keep the frontend window small & introduce recurrent connections: layers with persistent state, so they can reuse the computation they did last frame. Earshot's RNN layers learn to onset from noise → voice quickly, but hold off going from voice → noise for a bit, which is exactly what you want from a VAD.
There are a few problems with your average RNN layers like LSTM or GRU that make them tricky to use in Earshot, though. For one, they typically use nonlinear activation functions like tanh and sigmoid, which are difficult/expensive to implement in fixed-point. For two, they don't parallelize very well in training: they're sequential by definition since the output for each timestep depends on the output for the previous timestep. To train a good VAD, you need a lot of data; to get through a lot of data in a reasonable time, you need good parallelization (nope) or good hardware. I have an RTX 3060 -- not exactly the pinnacle of deep learning GPUs. Luckily, I had a trick up my sleeve: this super underrated paper that introduced minGRU, a simplified, parallelizable version of GRU, which made it possible to train Earshot 1.2 in a reasonable amount of time.
Now's the time for me to confess something. All that fixed-point stuff I did earlier kinda lobotomized the model - accuracy ended up a few points worse than Earshot 1.2. Better than the 30-point loss with the old QAT, but still not great. It was clear some architectural improvements were needed to make up for that gap, and I think I knew where to look. minGRU's gate (how much to update the previous state with the new state) is only dependent on its input; in GRU, it's also dependent on the GRU's own previous state. This means that minGRU makes a blind guess as to how much of its previous state to keep. The paper shows that's acceptable on many tasks, but those experiments were with deeper models, where later layers could see earlier layers' previous states via their outputs; Earshot only has 2 minGRU layers, so that route is close to nonexistent. I came up with my own shoddy fixed-point-friendly minGRU-ish-but-more-recurrent layer I call HRU, writing a custom GPU kernel so it wouldn't take forever to train (it took forever to write instead!) HRU finally brought accuracy back above Earshot 1.2 levels without incurring too much overhead at inference time.
Speaking of overhead at inference time! The recurrent layers are actually the most computationally intensive part of the neural network, since they use relatively large matmuls. Making them fixed-point in 1.2 reduced their cost, but now that the rest of the network is fixed-point too, they're back to taking up a big chunk of the processing time. Remember how the gate defines how much to update the previous state with the new state? That's per-channel, and each HRU has 64 channels. So each HRU needs to calculate 64 gates and 64 new states. But wait! What if a channel doesn't introduce any new state at all? A long stretch of noise shouldn't need to change much state at all; a gate that's fully closed (= 0) means the state stays exactly as it was, so we don't even need to calculate the new state. I managed to train the model to only open about 30% of gates on average, which sped up the HRUs quite a bit after adding logic to skip computing new state for channels whose gates are closed.
Each layer still had to calculate all 64 gates, though, and calculating the gate is just as expensive as calculating the new state. I made each gate cover 2 state channels, reducing the number of gates per layer to 32. To top things off, I reformulated the state calculation to remove slow 64-bit multiplies. In total, 2.0's new HRU layers cut inference time by 20% compared to 1.2's minGRUs!
Just 7 more lanes bro
By now, Earshot takes 2.9μs per prediction (down from 4.4μs). We're about at the limit of how it can be optimized computationally & architecturally, so it's time to dive into the assembly and start thinking about how to optimize it for the CPU's pipeline. Looking at cargo show-asm, it was clear that LLVM's auto-vectorization was struggling to understand the code in some spots. I don't blame it - at this point, I hardly could either. But if I wanted to go sub-microsecond (and I really did), I was going to have to write a hell of a lot of SIMD code.
It's times like this where I wish Rust's Portable SIMD was stable, especially since I committed myself to supporting as many architectures as possible. I ended up implementing my own shoddy portable SIMD wrapper, which the preprocessor/neural network predictor use for the 128-bit SIMD ISAs - SSE, NEON, and WASM SIMD. (well, NEON actually has its own predictor implementation to take advantage of vmlal instead of emulating madd...)
Auto-vectorization couldn't touch much of the preprocessor because the layout didn't allow for it, not simply because LLVM missed opportunities. My manual SIMD preprocessor implementations store real & complex values in the much friendlier planar format, rather than interleaved as in the scalar implementation. All SIMD preprocessors are floating-point only, again due to the lack of 64-bit mul SIMD instructions in most ISAs. The predictor also required a few layout changes of its own, and benefited significantly from aligning loads of weights/stores of activations to the vector size.
I started with AVX2, then ported that to SSE2, then generic-ized that to use my pseudo-portable SIMD wrapper to get NEON/WASM SIMD for basically free (before realizing NEON would benefit from its own predictor). I added AVX-512 last minute, but I don't have a machine that supports it, so I have no idea if it actually works (would appreciate if someone could test it and let me know!!) Earshot 1.2's full speed could only be realized if you compiled it with RUSTFLAGS="-C target-cpu=native" because it relied entirely on auto-vectorization. For 2.0, I wanted to add runtime SIMD feature detection so RUSTFLAGS wouldn't be required to get that sweet sweet speeeeeeeeed. You'll notice that nearly every function in one of the SIMD implementations is peppered with #[inline(always)] - that's needed to get #[target_feature] to propagate, and, fun fact, that propagation doesn't extend to closures! If a function or closure doesn't inherit #[target_feature(enable = "avx2")] for instance, it won't inline any AVX2 intrinsics, turning each one into a slow function call instead. That was fun to figure out...
The result
On my machine (Ryzen 7 5800X), the new AVX2 predictor + preprocessor run at about 840 nanoseconds per 16ms frame on real speech data (it varies based on the input due to the HRU gate skipping). That's close enough to 20,000x real time that you can surely forgive me for rounding up a little. Runtime SIMD detection adds very little overhead (most of it is just from things like normalization getting autovec'd to SSE instead of AVX). With the fully fixed-point pipeline, Earshot 2.0 runs on a Raspberry Pi Pico at about 6x real time. It's a $1 chip, be nice to it!
Earshot is licensed under MIT or Apache-2.0, also has bindings for C/C++ & Python, and supports literally any platform. All of this took a lot of work, so I hope someone out there can find Earshot 2.0 useful =)
r/rust • u/KeironLowe • 15h ago
🎙️ discussion Laravel Rust
I’m primarily a PHP engineer, but wondering how the Rust Community feel about the announcement of Laravel Rust (https://laravel.com/rust)?
r/rust • u/Acrobatic_Local5981 • 21h ago
📸 media GitHub Language Trends - November: Rust all time high at position 3
r/rust • u/PurpleWho • 6h ago
🛠️ project Anyone want to work through 100 Exercises to Learn Rust together? (Daily, 5–8 am IST)
I’m looking for a few people to work through 100 Exercises to Learn Rust with me, using the exercise repo.
The idea is simple: we get on a video call for an hour each day and work through the exercises at our own pace. We can stay muted. The point is to block out the time and know someone else will show up.
This is my third go at learning Rust. The last two got pushed aside when work got busy, so I’d like to make it a habit this time. I’m in India and start work at 9 am, so I’m looking for a one-hour slot between 5 and 8 am IST (UTC+5:30).
If you’re up for it, comment or DM me with your time zone and which hour works for you. A small group would be great, but I’m happy to start with one other person.
r/rust • u/hrubydavid • 1h ago
🙋 seeking help & advice 50 days of 1BRC in Rust: 0.398s on 8 cores. Anyone know a faster/interesting Rust solution? Or other things that are worth a look?
Hey r/rust
For the past ~50 days I've been practicing Rust by doing the One Billion Row Challenge. I followed Jon Gjengset's youtube stream and then kept going on my own. I'm now at 0.398s for 1B rows on 8 cores (AWS r8a.2xlarge Zen 5 with the file in tmpfs). I'm quite happy with that. I found only austindonisan's C solution faster and very interesting (0.311s). Does any body know faster Rust one, pretty please? I've already checked Ragnar Groot Koerkamp one and barr-israel one.
I enjoyed it even more than I expected mostly because of a few things I got to learn:
- mmap
- SIMD / SWAR
- compilator hints / PGO
- branches optimization / own hash table
I'm asking about faster (Rust) solutions just because I'd like to enjoy this even more. Or do you know other things that are worth a look, pretty please? Like my PGO shock 😮 A simple analysis of what PGO did showed me that one cold_path hint gives the same result and it saved a lot 🚀
r/rust • u/modulovalue • 8h ago
📸 media Looking for feedback on a Rust vs. Dart SIMD comparison for ASCII validation
Hello everyone,
I'm working on better support for SIMD in Dart (https://github.com/dart-lang/sdk/issues/64170). My goal is to expose the Wasm SIMD API through a convenient interface which seems to be a shared goal with std::simd.
I plan to publish a blog post where I share techniques on how to arrive at an efficient ASCII validator with SIMD.
I don't write Rust professionally, so I wanted to ask for some feedback to make sure that my comparison against Rust is fair in terms of readability and performance.
To demonstrate auto-vectorized performance I plan to share the following:
I will also include <[u8]>::is_ascii in the comparison, but to show how it could be implemented manually, I plan to demonstrate the performance of std::simd:
use *;
The equivalent Dart API that I'm working toward making possible is:
// The pragmas remove bounds checks and interrupt checks
@pragma('vm:unsafe:no-bounds-checks')
@pragma('vm:unsafe:no-interrupts')
bool u8x16Unroll16(Uint8List b) {
final n = b.length & ~255;
Uint8x16 acc = Uint8x16.zero;
int i = 0;
for (; i < n; i += 256) {
final t0 = Uint8x16.load(b, i + 0) | Uint8x16.load(b, i + 16);
final t1 = Uint8x16.load(b, i + 32) | Uint8x16.load(b, i + 48);
final t2 = Uint8x16.load(b, i + 64) | Uint8x16.load(b, i + 80);
final t3 = Uint8x16.load(b, i + 96) | Uint8x16.load(b, i + 112);
final t4 = Uint8x16.load(b, i + 128) | Uint8x16.load(b, i + 144);
final t5 = Uint8x16.load(b, i + 160) | Uint8x16.load(b, i + 176);
final t6 = Uint8x16.load(b, i + 192) | Uint8x16.load(b, i + 208);
final t7 = Uint8x16.load(b, i + 224) | Uint8x16.load(b, i + 240);
acc |= ((t0 | t1) | (t2 | t3)) | ((t4 | t5) | (t6 | t7));
}
for (; i + 16 <= b.length; i += 16) {
acc |= Uint8x16.load(b, i);
}
int tail = 0;
for (; i < b.length; i++) {
tail |= b[i];
}
return acc.signMask == 0 && tail < 0x80;
}
Any feedback would be appreciated, and if you can make the Rust version faster or more readable, I'd love to see it.
r/rust • u/BraveCake_ • 1h ago
🙋 seeking help & advice Login and key encryption solution for and offline+online application
I’m building a desktop application primarily using Rust and Tauri. The application requires an internet connection initially to fetch data from a server. However, once the initial data has been downloaded, it should work entirely offline, without requiring an active internet connection. Any changes made locally can then be synced back to the server when connectivity is restored.
I want to implement authentication and encryption to make the application more secure, but I’m having trouble figuring out the right architecture for this.
Here’s the approach I was initially considering:
Online authentication
- The user enters their username and password.
- The Rust backend sends the credentials to the server for verification.
- Upon successful authentication, the server returns the user’s profile along with access and refresh tokens.
- I use Tauri Stronghold to create a separate vault for the user and securely store the authentication tokens and database encryption key.
- The vault itself is protected using a key derived from the user’s password and a randomly generated salt, using Argon2id.
Offline authentication
- After the user’s first successful online login, their vault and local profile are already stored on the machine.
- When the user subsequently opens the application without an internet connection, they enter their password.
- The application derives the vault key again using Argon2id.
- If the derived key successfully unlocks the vault, the user can access their locally stored database and continue working offline.
This is the general architecture I have in mind, but I’m not entirely confident about it. It feels somewhat clunky, and I’m wondering if there is a better or more established approach to handling this.
My questions are:
- Is there a better architecture or authentication flow for an application that needs to support both online and offline authentication?
- Are there any established libraries, frameworks, or architectural patterns in Rust/Tauri that could simplify this implementation?
I’d appreciate any suggestions, particularly around security best practices and how to structure the authentication, key management, and offline access flows.
r/rust • u/Karrot1607 • 1h ago
Need Guidance
Hi, I am a MCA student first sem, I am not very good with coding but interested in AI,LLMS,RAG and also recently I was thinking of learning rust, should I learn rust ? If yes then please do tell the resources from where I can learn
r/rust • u/quest_for_7c • 20h ago
Where your stack lives can move a benchmark by 50%
heikoseeberger.der/rust • u/cobweb6542 • 1d ago
🎙️ discussion The more I use Rust, the more I appreciate how easy it makes refactoring
Probably not an unpopular opinion here, but being able to change an enum or restructure a type and just follow the compiler errors until everything fits together is genuinely nice.
Especially when working on larger codebases. I'd much rather deal with 50 compiler errors than spend hours tracking down something I forgot to update.
Curious if anyone else finds refactoring to be one of the biggest reasons they stick with Rust.
r/rust • u/EuroRust • 22h ago
The Future of Unmanned Systems Is Built on Rust - Benedikt Wiethof & Theophil Spiegeler Castañeda | EuroRust 2026
youtube.comA new video is out on YouTube! 📺 At EuroRust, Benedikt and Theophil from Quantum Systems shared why and how they rewrote their drone ground control station from C++ to Rust, and what it means for the next generation of unmanned systems 🦀✨
In 2027 EuroRust is going to Prague! Learn more and get your ticket at eurorust.eu.
r/rust • u/TheAnalist_ • 1d ago
🎙️ discussion borrIR borrow checker for LLVM IR
what do y’all think of this new borrow checker for LLVM IR and what can the rust compiler learn from this?
https://fzakaria.com/2026/11/27/programming-languages-are-for-humans
r/rust • u/NeyaVexy • 8h ago
Rust's strictness saved me from a subtle bug that would have been invisible in most other languages
I was refactoring a small background worker that processes tasks from a queue. The task struct had an optional “retry_until” timestamp that was only supposed to be set for certain failure modes.
In the middle of the change I accidentally left one code path that could set the field on a success result. The borrow checker and exhaustive match arms didn't catch it because the types still lined up. What did catch it was a single extra variant I had added to an internal enum purely for my own clarity.
The compiler forced me to handle the new case everywhere, and one of those places revealed the impossible state I had just created. I would have shipped it otherwise.
It's the kind of thing that usually only shows up in production after a weird retry loop. Curious how often other people have had the type system surface a logic error they didn't even realize they'd written.
r/rust • u/laserdataInc • 6h ago
How do you hand a partition from one consumer to another without double processing?
When a consumer joins or leaves a group, partitions move, and the risky moment is the handover: the old owner may still be finishing a message while the new one starts reading. We're working through this in a Rust streaming server and want the handover right before anything else.
How have you handled it: stop-the-world rebalances, cooperative handover, fencing the old owner? What caused duplicates or stalls for you?
🎙️ discussion How much on scale 1 to 5, do you wish to see documentation directly tied to the method body as standard doc comment?
The IDE intellisence will still show the same documentation when hovering over the method identifier. So only difference is code readability for auditing purposes or for maintainers.
I've been developing library that uses a lot of this pattern, and copy pasting the documentation definitely feels "wrong".
r/rust • u/derekleeth • 9h ago
My Tauri app used 1.7 GB to print a 50 MB log. Fixed it, then compared it to two Electron apps doing the same thing
Coming from ~20 years of Python, my first real Rust project is an SSH client built with Tauri 2 (russh for SSH, xterm.js for the terminal). I'd heard "Tauri uses way less memory than Electron" a bunch, so I finally measured it against two popular Electron SSH clients. Figured some of you might find the numbers interesting, especially since mine didn't come out looking great at first. lol
How I measured: same Windows PC, same SSH server, private memory summed over every process each app starts (WebView2 / Electron helpers included), median of 3 runs. Nothing fancy, just PowerShell sampling the process tree.
At rest, Tauri wins pretty easily:
| Scenario | Mine (Tauri) | Electron app A | Electron app B |
|---|---|---|---|
| Idle after launch | 208 MB | 850 MB | 360 MB |
| One idle SSH session | 242 MB | 944 MB | 380 MB |
| Ten idle sessions | 429 MB | 1,620 MB | 547 MB |
| Each extra tab | ~21 MB | ~75 MB | ~19 MB |
So 3.8–4.1x less than A, but only 1.3–1.7x less than B, and B's tabs are actually a little cheaper than mine. "Electron = bloated" depends a lot on the app.
Then I ran cat on a 50 MB log, and mine fell over:
cat 50 MB | Mine, before | Mine, after the fix | Electron A | Electron B |
|---|---|---|---|---|
| Peak memory | 1,677 MB | 355 MB | 1,275 MB | 703 MB |
| CPU time | 41 CPU-s | 6.1 CPU-s | 4.5 CPU-s | 7.4 CPU-s |
| Time to finish drawing | ~10.7 s | ~2 s | ~2–3 s | ~4 s |
| Memory left over afterwards | +290 MB | ~+30 MB | about 0 | ~+95 MB |
1.7 GB to print a log. And Ctrl+C was useless, because the whole file had already been sent within about a second.
What was wrong: nothing pushed back. My russh read loop sent every chunk straight to the frontend as its own Tauri channel message, the webview queued them, and I called term.write() without a callback, so xterm.js queued everything too. The whole file ended up sitting in memory a few times over.
The fix (basically xterm.js's flow control guide, carried back to the socket):
- Batch output on the Rust side: up to 512 KB, or whatever arrived within 4 ms, as one message.
- Count bytes sent but not drawn yet. Above 2 MB the read loop just stops calling
reader.wait(); below 512 KB it starts again. - The terminal sends an ack every 64 KB from
term.write's callback. - If no ack shows up for 2 s while paused (Android freezes backgrounded webviews), let output flow until acks come back, so nothing hangs.
Something I learned along the way: russh reopens the SSH window as data arrives, not as you read it. But its per-channel queue is bounded, so once you stop reading, the backpressure still reaches the server through TCP. Ctrl+C now brings the prompt back immediately, and yes levels off around 350 MB instead of growing forever.
The CPU part surprised me. Even after the memory was fixed, CPU was high, and profiling showed xterm.js parsing was under a second of it. Most of it was the cost per message: a Tauri channel message over 1 KB gets fetched by the webview through a custom scheme, so every message is an eval + fetch round trip through several processes. Going from 64 KB to 512 KB batches (about 800 messages down to about 100) cut CPU roughly in half.
Where I've landed: Tauri clearly wins on memory, both at rest and under load now. On CPU for heavy output, Electron A still beats me (4.5 vs 6.1 CPU-s), I think because it gets its bytes without an IPC hop like mine. And for perspective, a native (non-webview) client I tested used about a third of my memory at rest, so the OS webview definitely isn't free.
Has anyone found a cheaper way to push bulk bytes from Rust into a Tauri 2 webview than channel messages? That's the last chunk of overhead I haven't been able to get rid of.