Maybe Rust isn’t a good tool for massively concurrent, userspace software
OK, I suppose I should write to this.<p>As I&#x27;ve mentioned before, I&#x27;m writing a high performance metaverse client. Here&#x27;s a demo video.[1]
It&#x27;s about 40,000 lines of Rust so far.<p>If you are doing a non-crappy metaverse, which is rare, you need to wrangle a rather excessive amount of data in near real time. In games, there&#x27;s heavy optimization during game development to prevent overloading the play engine. In a metaverse, as with a web browser, you have to take what the users create and deal with it. You need 2x-3x the VRAM a comparable game would need, a few hundred megabits per second of network bandwidth to load all the assets from servers, a half dozen or so CPUs running flat out, and Vulkan to let you put data into the GPU from one thread while another thread is rendering.<p>So there will be some parallelism involved.<p>This is not like &quot;web-scale&quot; concurrency, which is typically a large number of mini-servers, each doing their own thing, that just happen to run in the same address space. This is different. There&#x27;s a high priority render thread drawing the graphics. There&#x27;s a update thread processing incoming events from the network. There are several asset loading and decompression threads, which use up more CPU time than I&#x27;d like. There are about a half dozen other threads doing various miscellaneous tasks - handling moving objects, updating levels of detail, purging caches, and such.<p>There&#x27;s considerable locking, but no &quot;static&quot; data other than constants. No globals. 
Channels are used where appropriate to the problem. The main object tree is single ownership, and used mostly by the update thread. Its links to graphics objects are Arc reference counted, and those are updated by both the update thread and the asset loading threads. They in turn use reference counted handles into the Rend3 library, which, via WGPU and Vulkan, puts graphics content (meshes and textures) into the GPU. Rendering is a loop which just tells Rend3 &quot;Go&quot;, over and over.<p>This works out quite well in Rust. If I had to do this in C++, I&#x27;d be fighting crashes all the time.
There&#x27;s a reason most of the highly publicized failed metaverse projects didn&#x27;t reach this level of concurrency.
In Rust, I have about one memory related crash per year, and it&#x27;s <i>always</i> been in someone else&#x27;s &quot;unsafe&quot; code. My own code has no &quot;unsafe&quot;, and I have &quot;unsafe&quot; locked out to prevent it from creeping in. The normal development process is that it&#x27;s hard to get things to compile, and then it Just Works.
That&#x27;s great! I hate using a debugger, especially on concurrent programs. Yes, sometimes you can get stuck for a day, trying to express something within the ownership rules. Beats debugging.<p>I have my complaints about Rust. The main ones are:<p>- Rust is race condition free, but not deadlock free. It needs a static deadlock analyzer, one that tracks through the call chain and finds that lock A is locked before lock B on path X, while lock B is locked before path A on path Y. Deadlocks, though, tend to show up early and are solid problems, while race conditions show up randomly and are hard to diagnose.<p>- Async contamination. Async is all wrong when there&#x27;s considerable compute-bound work, and incompatible with threads running at multiple priorities. It keeps creeping in. I need to contact a crate maintainer
and get them to make their unused use of &quot;reqwest&quot; dependent on a feature, so I don&#x27;t pull in Tokio. I&#x27;m not using it, but it&#x27;s there.<p>- Single ownership with a back reference is a very common need, and it&#x27;s too hard to do. I use Rc and Weak for that, but shouldn&#x27;t have to. What&#x27;s needed is a set of traits to manage consistent forward and back links (that&#x27;s been done by others) and static analysis to eliminate the reference counts.
The basic constraints are ordinary borrow checker restrictions - if you have mutable access to either parent or child, you can&#x27;t have access to the other one. But you can have non-mutable access to both.
If I had time, I&#x27;d go work on that.<p>- I&#x27;ve learned to live without objects, but the trait system is somewhat convoluted.
There&#x27;s one area of asset processing that really wants to be object oriented, and I have more duplicate code
there than I like. I could probably rewrite it to use traits more, but it would take some bashing to make
it fit the trait paradigm.<p>- The core graphics crates aren&#x27;t finished. There was an article on HN a few days ago about this. &quot;Rust has 5 games and 50 game engines&quot;. That&#x27;s not a language problem, that&#x27;s an ecosystem problem. Not enough people are doing non-toy graphics in Rust. Watch my video linked below.[1] Compared to a modern AAA game title, it&#x27;s not that great. Compared to anything else being done in Rust (see [2]) it&#x27;s near the front.
This indicates a lack of serious game dev in Rust.
I&#x27;ve been asked about this by some pro game devs.
My comment is that if you have a schedule to meet, the Rust game ecosystem isn&#x27;t ready.
It&#x27;s probably about five people working for a year from being ready.<p>[1] <a href="https:&#x2F;&#x2F;video.hardlimit.com&#x2F;w&#x2F;tp9mLAQoHaFR32YAVKVDrz" rel="nofollow noreferrer">https:&#x2F;&#x2F;video.hardlimit.com&#x2F;w&#x2F;tp9mLAQoHaFR32YAVKVDrz</a><p>[2] <a href="https:&#x2F;&#x2F;gamedev.rs&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;gamedev.rs&#x2F;</a>