<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <updated></updated>
  <generator>https://njump.me</generator>

  <title>Nostr notes by </title>
  <author>
    <name></name>
  </author>
  <link rel="self" type="application/atom+xml" href="https://njump.me/npub17y2jf0ykldyfuswske4ez23qy0f4q2xylfwq7vctlh4u8a3dr8ds8s5h4m.rss" />
  <link href="https://njump.me/npub17y2jf0ykldyfuswske4ez23qy0f4q2xylfwq7vctlh4u8a3dr8ds8s5h4m" />
  <id>https://njump.me/npub17y2jf0ykldyfuswske4ez23qy0f4q2xylfwq7vctlh4u8a3dr8ds8s5h4m</id>
  <icon></icon>
  <logo></logo>




  <entry>
    <id>https://njump.me/nevent1qqst38hxd4t3ddv0drdjwsc2u0v6n4a4sk8x8243qk8anxm4uvnakeczyrc32f9ujma538jp6zmxhyf2yq3ax5pgcna9crenp077hslk95vakr8jpmp</id>
    
      <title type="html">Yet Another Performance Footgun in Rust - Multithreading Lock ...</title>
    
    <link rel="alternate" href="https://njump.me/nevent1qqst38hxd4t3ddv0drdjwsc2u0v6n4a4sk8x8243qk8anxm4uvnakeczyrc32f9ujma538jp6zmxhyf2yq3ax5pgcna9crenp077hslk95vakr8jpmp" />
    <content type="html">
      Yet Another Performance Footgun in Rust - Multithreading Lock Edition&lt;br/&gt;&lt;br/&gt;It turns out that RAII can lead to performance &amp;#34;footguns&amp;#34;, not just regarding memory, but also with multithreading locks.&lt;br/&gt;The &amp;#34;holding a mutex longer than necessary&amp;#34; footgun.&lt;br/&gt;It’s easy to fall into this trap :&lt;br/&gt;{&lt;br/&gt;let data = data.lock()&lt;br/&gt;data.update(10)&lt;br/&gt;// ...lots of other code...&lt;br/&gt;}&lt;br/&gt;Oops, the mutex remains locked for the entire duration of the scope, even though it only needed to be held until the final write to the data variable. This degrades performance because other threads are forced to wait longer than they should. The performance hit, latency and throughput, scales linearly with the amount of code executed after the last write, the longer that code takes to reach the end of the scope, the more severe the latency increase and throughput drop become.&lt;br/&gt;This footgun appears frequently in real world code, as many developers write &amp;#34;vanilla&amp;#34; Rust without manually managing the lifetime of these locks. One might suggest calling drop explicitly or wrapping the logic in an inner scope, but neither is a robust or reliable solution. Why? Because both require manual awareness, in other words, they rely on the developer&amp;#39;s skill to do so. By definition, a &amp;#34;footgun&amp;#34; is something that catches users off guard, often without them even realizing it.&lt;br/&gt;So, what is the solution? As it turns out, &amp;#34;ASAP drop&amp;#34; (dropping as soon as possible) can resolve not only memory related footguns but also performance issues stemming from multithreading locks.&lt;br/&gt;Visualization :&lt;br/&gt;let data = data.lock().unwrap() // `data` becomes a `MutexGuard&amp;lt;T&amp;gt;`&lt;br/&gt;data.update(10)&lt;br/&gt;data.update(20)&lt;br/&gt;// The compiler analyzes when the `MutexGuard&amp;lt;data&amp;gt;` is last used.&lt;br/&gt;// If the code above represents the final access, the compiler automatically inserts an unlock operation immediately afterward.&lt;br/&gt;// This allows other threads to take their turn without any unnecessary, prolonged waiting.&lt;br/&gt;data.unlock() // Inserted by the compiler&lt;br/&gt;As a further implementation guide, since read access is safe to perform from multiple threads, the unlock operation is inserted immediately after the final write, detected via &amp;amp;mut references, interior mutability, and raw mutable pointers (*mut). The final read access, using &amp;amp; and *const, does not extend the lifetime of the MutexGuard. This ensures that other threads get their turn as soon as possible, eliminating wasted time, resulting in low latency and high throughput right out of the box.&lt;br/&gt;8 posts - 3 participants&lt;br/&gt;Read full topic&lt;br/&gt;&lt;br/&gt;&lt;a href=&#34;https://internals.rust-lang.org/t/yet-another-performance-footgun-in-rust-multithreading-lock-edition/24726&#34;&gt;https://internals.rust-lang.org/t/yet-another-performance-footgun-in-rust-multithreading-lock-edition/24726&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#rust #footgun #mutexguard&lt;br/&gt;&lt;br/&gt;#rss #feeds #linksharing #qwibbit
    </content>
    <updated>2026-10-30T04:51:10Z</updated>
  </entry>

  <entry>
    <id>https://njump.me/nevent1qqsfsdkhzxu6h7995987vq3yw2pyqh420kf7pz2hrj4d5zxd8zgkhfqzyrc32f9ujma538jp6zmxhyf2yq3ax5pgcna9crenp077hslk95vakfpm93u</id>
    
      <title type="html">SAFETY comments - nomicon This, in an ongoing discussion on URLO, ...</title>
    
    <link rel="alternate" href="https://njump.me/nevent1qqsfsdkhzxu6h7995987vq3yw2pyqh420kf7pz2hrj4d5zxd8zgkhfqzyrc32f9ujma538jp6zmxhyf2yq3ax5pgcna9crenp077hslk95vakfpm93u" />
    <content type="html">
      SAFETY comments - nomicon&lt;br/&gt;&lt;br/&gt;This, in an ongoing discussion on URLO, really hit home for me too.&lt;br/&gt;Jookia:&lt;br/&gt;Looking at the random crates I have downloaded, sdl3-sys, sdl3-rs, parley, fontations, they all use unsafe without a SAFETY quite a lot. std is even guilty of it, but seems to follow the suggestions here more. I tend to learn by doing or reading other people&amp;#39;s work so this is where a source of my confusion comes from.&lt;br/&gt;I&amp;#39;ve also noticed that there are some excellent examples of SAFETY comments and many, very many, examples of unsafe with no comments.&lt;br/&gt;While agreeing with the OP, I thought &amp;#34;I&amp;#39;ll refer to the nomicon, that will contain great guidelines on how to add SAFETY comments to code ...&amp;#34; - oops!&lt;br/&gt;The nomicon doesn&amp;#39;t mention SAFETY comments once, nor safety-related lints&lt;br/&gt;While it does include inline comments in the &amp;#34;implementing Vec&amp;#34; example - they don&amp;#39;t match today&amp;#39;s expectations for format or content&lt;br/&gt;I&amp;#39;d like to suggest raising a PR to the nomicon to:&lt;br/&gt;add a dedicated section 1.4 &amp;#34;Documenting &amp;amp; auditing unsafe code&amp;#34; covering how to write safety comments as well as the fundamental rustc &amp;amp; clippy lints&lt;br/&gt;update the implementing Vec example to include exemplary safety documentation&lt;br/&gt;Given that we should expect a significant increase in the amount of unsafe being written in the next year, I&amp;#39;d consider now to be the right time to get ahead of this and hopefully push towards a positive feedback loop with more of that code including good comments.&lt;br/&gt;I&amp;#39;d be happy to work on this, but only if it has a chance of landing&lt;br/&gt;2 posts - 2 participants&lt;br/&gt;Read full topic&lt;br/&gt;&lt;br/&gt;&lt;a href=&#34;https://internals.rust-lang.org/t/safety-comments-nomicon/24721&#34;&gt;https://internals.rust-lang.org/t/safety-comments-nomicon/24721&lt;/a&gt;&lt;br/&gt; &lt;img src=&#34;https://emoji.discourse-cdn.com/twitter/wink.png?v=16&#34;&gt; &lt;br/&gt;&lt;br/&gt;#safetycomments #nomicon #vec #urlo #looking #documenting&lt;br/&gt;&lt;br/&gt;#rss #feeds #linksharing #qwibbit
    </content>
    <updated>2026-10-29T18:12:53Z</updated>
  </entry>

  <entry>
    <id>https://njump.me/nevent1qqs8gycdu0c0egqcjy5h2q3ss0u30l8exg6r2tdd4m3rd7pajtdmelczyrc32f9ujma538jp6zmxhyf2yq3ax5pgcna9crenp077hslk95vakn7hdcm</id>
    
      <title type="html">Attempting to clean up the feature activation syntax? Currently, ...</title>
    
    <link rel="alternate" href="https://njump.me/nevent1qqs8gycdu0c0egqcjy5h2q3ss0u30l8exg6r2tdd4m3rd7pajtdmelczyrc32f9ujma538jp6zmxhyf2yq3ax5pgcna9crenp077hslk95vakn7hdcm" />
    <content type="html">
      Attempting to clean up the feature activation syntax?&lt;br/&gt;&lt;br/&gt;Currently, a feature activation in the manifest can include:&lt;br/&gt;&amp;#34;foo&amp;#34;: activate the feature foo in the current package&lt;br/&gt;&amp;#34;dep:foo&amp;#34;: activate the optional dependency foo&lt;br/&gt;&amp;#34;foo?/bar&amp;#34;: if the optional dependency foo is activated, activate the feature bar within it&lt;br/&gt;&amp;#34;foo/bar&amp;#34;:&lt;br/&gt;If foo is non-optional dependency, activate the feature &amp;#34;bar&amp;#34; within it&lt;br/&gt;If foo is an optional dependency, activate it, activate a feature named foo if present, and activate the feature bar&lt;br/&gt;On the command line with resolver = &amp;#34;2&amp;#34; or later,&lt;br/&gt;-F foo: activate foo within any selected packages that have it&lt;br/&gt;-F foo/bar&lt;br/&gt;If foo is a dependency of a selected package, treat foo/bar like it was in a manifest&lt;br/&gt;Else if foo is a workspace member, activate bar within it&lt;br/&gt;Problems with this&lt;br/&gt;It is hard to know what all these different forms are and their subtle meaning (e.g. I&amp;#39;m not sure that my summary is 100% accurate)&lt;br/&gt;Feels weird that -F foo/bar might not just activate bar but could also be equivalent of -F foo,foo/bar&lt;br/&gt;It is too easy to accidentally use &amp;#34;foo/bar&amp;#34; and pull in a dep and never realize it (Lint for suspicious optional dependency activation · Issue #17639 · rust-lang/cargo · GitHub)&lt;br/&gt;Processing &amp;#34;foo/bar&amp;#34; requires knowledge of the full manifest to know what it translates to (which caused us problems with the path we were taking on RFC #3491 which cause it to be pulled from the 2024 edition at the last minute)&lt;br/&gt;I&amp;#39;ve occasionally been confused that &amp;#34;foo?/bar&amp;#34; isn&amp;#39;t &amp;#34;dep:foo?/bar&amp;#34; though from other perspectives, foo?/bar makes sense to me&lt;br/&gt;Additional context&lt;br/&gt;We are phasing out being able to refer directly to optional deps (RFC 3491)&lt;br/&gt;I have some other ideas for activating more non-feature items, like dep: does for dependencies&lt;br/&gt;So how should we clean this up?&lt;br/&gt;3 posts - 2 participants&lt;br/&gt;Read full topic&lt;br/&gt;&lt;br/&gt;&lt;a href=&#34;https://internals.rust-lang.org/t/attempting-to-clean-up-the-feature-activation-syntax/24718&#34;&gt;https://internals.rust-lang.org/t/attempting-to-clean-up-the-feature-activation-syntax/24718&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;#rss #feeds #linksharing #qwibbit
    </content>
    <updated>2026-10-29T14:04:24Z</updated>
  </entry>

</feed>